1/26 Lab: Blinking LED

Posted by melissa

melissa's picture

 

Description

Use the Arduino to control a light emitting diode and make it blink in different rate.

Components Used

  • Light Emitting Diode (LED)
  • Resistor

Arduino Code:

/*
  Blink
 2 LEDs blink for 1 second repeatedly. 
 
  This example code is in the public domain.
 */
 
void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
  pinMode(12, OUTPUT);
}
 
void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  digitalWrite(12,HIGH); // set 2nd LED on
  delay(1000);              // wait for a second
  digitalWrite(12,LOW); //set 2nd LED off
}
 
Blinking LEDs
5
Your rating: None Average: 5 (1 vote)