Datasheet
Shield, Lights, Servo Motors • Chapter 2
Robotics with the BOE Shield-Bot • 55
Try modifying your sketch to use delay(250). Don’t forget to change it in both
places!
How far can you reduce the delay before it just looks like the LED is dim instead
of blinking on/off? Try it!
Blinking the pin 12 LED is a simple matter of changing the
pin parameter in the pinMode
and two
digitalWrite function calls.
Modify the sketch so that
pinMode in the setup function uses pin 12 instead of
pin 13.
Also modify both
digitalWrite statements in the loop function to use pin 12.
Run it, and make sure the pin 12 LED blinks.
Make both LEDs blink at the same time, by adding statements to the sketch
using
pinMode twice:
pinMode(13, OUTPUT); // Set digital pin 13 -> output
pinMode(12, OUTPUT); // Set digital pin 12 -> output
….and using digitalWrite four times:
digitalWrite(13, HIGH); // Pin 13 = 5 V, LED emits light
digitalWrite(12, HIGH); // Pin 12 = 5 V, LED emits light
delay(500); // ..for 0.5 seconds
digitalWrite(13, LOW); // Pin 13 = 0 V, LED no light
digitalWrite(12, LOW); // Pin 12 = 0 V, LED no light
delay(500); // ..for 0.5 seconds
Run the modified sketch. Do both LEDs blink on and off together?
How would you modify the sketch again to turn one LED on while the other turns off? One
circuit will need to receive a
HIGH signal while the other receives a LOW signal.
Try it!
Activity 3: LED Servo Signal Monitors
The high and low signals that control servo motors must last for very precise periods of time.
That’s because a servo motor measures how long the signal stays high, and uses that as an
instruction for how fast, and in which direction, to turn its motor.
This timing diagram shows a servo signal that would make your Shield-Bot’s wheel turn full
speed counterclockwise. There’s one big difference though: all the signals in this timing
diagram last 100 times longer than they would if they were controlling a servo. This slows it
down enough so that we can see what’s going on.