Description
I used an Arduino UNO, a blue LED, a red LED, and two 220 ohm resistors. I changed the Arduino sample code to blink one LED twice, then blink the other LED once.
Components
- Arduino UNO
- 1 blue LED
- 1 red LED
- 2 220 ohm resistors
- a breadboard
Code
/*
Blinks 2 LEDs, the 1st for 2 beats,
and the 2nd for 1 beat.
Code was modified from the Arduino sample code Blink_1_LEDs
*/
int ledPin1 = 4; //allow for variable output pin
int ledPin2 = 13; //allow for variable output pin
void setup()
{
pinMode(ledPin1, OUTPUT); // initialize output pins
pinMode(ledPin2, OUTPUT);
}
void loop() // the loop function runs repeatedly
{
digitalWrite(ledPin1, HIGH); // turn the LED1 on
delay(800); // wait
digitalWrite(ledPin1, LOW); // turn the LED1 off
delay(100);
digitalWrite(ledPin1, HIGH);
delay(800);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH); // turn the LED2 on
delay(400);
digitalWrite(ledPin2, LOW); // turn the LED2 off
}