9.5 Example: ledBlink
A simple script to blink an LED on and off is shown below.
/* ledBlink. This script will cause an LED attached to pin 11 to blink on and off rapidly. The delay(250) instructions will result in 250 ms, or 1/4 s, delays. The code turn on the LED for 1/4 s, off for 1/4 s. This corresponds to a blink rate of 1/(.25+.25)=1/.5 = 2 Hz. */
#define LED 11 void setup(){ pinMode(LED, OUTPUT); } void loop(){ digitalWrite(LED, HIGH); delay(250); digitalWrite(LED, LOW); delay(250); }