Introduction: Mini Arduino LED Christmas Lights

About: Hi, this page is about robotics, electronics, embedded systems, drones, RC and other cool DIY stuff. I aim to manufacture robots & electronics. To see the projects I am developing, visit my github: https:/…

Are you looking for a simple electronics project to get some practice with Arduino and PWM? Try this out!

What you need can be found on eBay (links below):

1 x Arduino UNO + USB cable

6 x Colour LED's of your choice (I used 3 red, 3 yellow)

6 x 1k Resistors

8 x Male-to-male jumper cables (I used 6 orange ones for the PWM signals and 2 for GND)

4 x Short breadboard wires to make common grounds from the LED's

1 x Mini prototyping breadboard

The 1k resistors are probably overkill, you can use less ohmage for more brightness. Just be careful not to draw more than 40mA per output pin or sink more than 200mA per ground pin.

Step 1: Wire Up the Circuit As Shown in the Image:

***NOTE: the LED cathodes (i.e. the pin at the flat edge) are negative, so they connect to ground. Wiring the LED's in reverse might destroy your Arduino.***

Step 2: Copy or Download the Code Below & Upload to Arduino

/*
6 LED Christmas Lights

This example shows how to fade six LED's on the pwm pins

using the analogWrite() function.

This concept code is based on the single led 'fade' example sketch.

*/

int ledPin1 = 3; // first LED on pin 3

int ledPin2 = 5; // second LED on pin 5

int ledPin3 = 6; // third LED on pin 6

int ledPin4 = 9; // fourth LED on pin 9

int ledPin5 = 10; // fifth LED on pin 10

int ledPin6 = 11; // sixth LED on pin 11

int brightness1 = 0; // minimum brightness

int brightness2 = 255; // maximum brightness

int fadeAmount = 51; // how many points to fade the LED by

// the setup routine runs once when you press reset:

void setup() {

// declare led pins to be outputs:

pinMode(ledPin1, OUTPUT);

pinMode(ledPin2, OUTPUT);

pinMode(ledPin3, OUTPUT);

pinMode(ledPin4, OUTPUT);

pinMode(ledPin5, OUTPUT);

pinMode(ledPin6, OUTPUT); }

// the loop routine runs over and over again forever:

void loop() {

// set the brightness of LED's:

analogWrite(ledPin1, brightness1);

analogWrite(ledPin2, brightness2);

analogWrite(ledPin3, brightness1);

analogWrite(ledPin4, brightness2);

analogWrite(ledPin5, brightness1);

analogWrite(ledPin6, brightness2);

// change the brightness for next time through the loop:

brightness1 = brightness1 + fadeAmount;

brightness2 = brightness2 - fadeAmount;

// reverse the direction of the fading at the ends of the fade:

if (brightness1 == 0 || brightness1 == 255){

fadeAmount = -fadeAmount;

}

// wait for 30 milliseconds to see the dimming effect

delay(30);

}

Step 3: Done!

If you found this instructable useful, why not stay tuned for future projects by following me on Instructables and on Facebook / Twitter / Google+.

If you enjoyed this instructable and would like to see more like this, please consider supporting me by purchasing your materials for this project through the affiliate links in the materials section or donating below:
PayPal: https://www.paypal.me/HobbyTransform

Bitcoin: 1Mqe7et24Lz4DY1RUN4iAQVHkvJsdFArKR

Ethereum: 0x6d8248db1cdea6a783cb6b41ae67bb8e6144f479

Litecoin: LW6PWESqsr8xHw6EJ9WLbsQsAyTvPnwnxJ

Dash: Xemv7jud697v8tQmKfNFoMxfkd17ZayH2t

Your support is greatly appreciated! Happy DIY'ing!