05d: Blinking LEDS

Clear your breadboard and let’s make CIRC-01, which is on Page 8 of the ARDX kit manual:

Copy the code from the manual, or from

Now make it blink faster!

Blinking 2 LEDs

int L1 =  13;    // LED connected to digital pin 13
int L2 =  12;    // LED connected to digital pin 12

// The setup() method runs once, when the sketch starts

void setup()   {                
  // initialize the digital pin as an output:
  pinMode(L1, OUTPUT);
  pinMode(L2, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                    
{
  digitalWrite(L1, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(L2, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(L1, LOW);    // set the LED off
  delay(1000);                  // wait for a second
  digitalWrite(L2, LOW);    // set the LED off
  delay(1000); 
}

Make them blink at the same time and alternated.

Blinking 3 LEDs

Now 3 LEDs!

int L1 =  13;    // LED connected to digital pin 13
int L2 =  12;    // LED connected to digital pin 12
int L3 =  11;    // LED connected to digital pin 11

// The setup() method runs once, when the sketch starts

void setup()   {                
  // initialize the digital pin as an output:
  pinMode(L1, OUTPUT);
  pinMode(L2, OUTPUT);
  pinMode(L3, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                    
{
  digitalWrite(L1, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(L2, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(L3, HIGH);    // set the LED off
  delay(1000);              // wait for a second
  digitalWrite(L1, LOW);    // set the LED off
  digitalWrite(L2, LOW);    // set the LED off
  digitalWrite(L3, LOW);    // set the LED off
  delay(1000);
}