Description
Use the Arduino to control a light emitting diode and make it blink in different rate.
Components Used
• Light Emitting Diode (LED)
• 220-ohm Resistor
Arduino Code
/* Blinking LED
* ------------
*
* turns on and off a light emitting diode(LED) connected to a digital
* pin, in intervals of 1 second. Ideally we use pin 13 on the Arduino
* board because it has a resistor attached to it, needing only an LED
*
* Created August 2011
* copyleft 2011 Wai Pio Fan
*
* based on an orginal by H. Barragan for the Wiring i/o board
*/
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(500); // waits for 0.5 second
digitalWrite(ledPin, LOW); // sets the LED off
delay(500); // waits for 0.5 second
}