Datasheet

Chapter 2 Shield, Lights, Servo Motors
54Robotics with the BOE Shield-Bot
/*
Robotics with the BOE Shield - HighLowLed
Turn LED connected to digital pin 13 on/off once every second.
*/
void setup() // Built-in initialization block
{
pinMode(13, OUTPUT); // Set digital pin 13 -> output
}
void loop() // Main loop auto-repeats
{
digitalWrite(13, HIGH); // Pin 13 = 5 V, LED emits light
delay(500); // ..for 0.5 seconds
digitalWrite(13, LOW); // Pin 13 = 0 V, LED no light
delay(500); // ..for 0.5 seconds
}
Introducing the Timing Diagram
A timing diagram is a graph that relates a signal's high and low stages to time. This timing
diagram shows you a 1000 ms slice of the
HIGH (5 V) and LOW (0 V) signals from the sketch
HighLowLed. Can you see how
delay(500) is controlling the blink rate?
Your Turn Experiment with the Blink Rates and Both LEDs
How would you make the LED blink twice as fast? How about reducing the delay function’s
ms parameters by half?