Christmas Lights Arduino project

The project

This project involves green and red LED lights which flash in an alternating pattern. In this project, you will use two LEDs but you can add as many as you want if you have enough jumper wires and LEDs.

Scroll down to view the instructions or click here to download a PDF copy of the instructions.

What you need:

  • 1 x Arduino Uno or compatible board
  • 1 x red LED
  • 1 x green LED
  • 2 x 470 Ohm resistor (yellow-violet-black-black-brown, or yellow-violet-brown-gold)
  • 1 x Solderless breadboard
  • 3 x jumper wires

Photos

Picture1 Picture2 Picture3

Wiring it up

Picture4
The LEDs are connected to pins 12 and 13 and each one has a 470 Ohm resistor connect to GND via the breadboard.

The code

Here is the Arduino sketch code:

/*
Christmas lights - blinking red and green LEDs
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int redLED = 13;
int greenLED = 12;
 
// the setup routine runs once when you press reset:
void setup() { 
 // initialize the digital pin as an output.
 pinMode(redLED, OUTPUT);
 pinMode(greenLED, OUTPUT); 
}
 
// the loop routine runs over and over again forever:
void loop() {
 digitalWrite(redLED, HIGH); // turn the LED on (HIGH is the voltage level)
 digitalWrite(greenLED, LOW); // turn the LED off by making the voltage LOW
 delay(100); // wait for a second
 digitalWrite(redLED, LOW); // turn the LED off by making the voltage LOW
 digitalWrite(greenLED, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(100); // wait for a second
}

Use the Arduino IDE to write this code, verify it and then upload it to the Arduino board. For an extra challenge, why not add a light sensor so that the lights only come on when it’s dark, or a button so that the lights can be switched on and off easily? You can also use a chain of LEDs instead of separately wiring them up to a breadboard.