Introduction: Mini Arduino LED Christmas Lights

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+.
I am a participant in the Amazon Services LLC Associates Program (and other potential affiliate networks), an affiliate advertising program designed to provide a means to earn fees by linking to Amazon.com and affiliated sites. While I may be compensated for sales derived through this website, my recommendations of these products are sincere and based on the first-hand experiences and reviews of real users I have uncovered through online research. 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 provided links in the materials section. Your support is greatly appreciated!

Happy DIY'ing!

Comments

author
seamster (author)2015-07-27

Nice!

author
HobbyTransform (author)seamster2015-07-27

Thanks!

About This Instructable

1,430views

8favorites

License:

Bio: 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 ... More »
More by HobbyTransform:Arduino Encoded and Modulated Laser and Infrared Serial CommunicationArduino OLED 128X64 IIC Serial Display: Printing Text and Moving ImagesMPU6050: Arduino 6 Axis Accelerometer + Gyro - GY 521 Test & 3D Simulation
Add instructable to: