Introduction: Arduino Chrismas Lights

About: I like Arduino, Raspberry Pi and Nividia Jetson

I wanted to make it as a proof of concept that we can have not just boring lights that are given by the monochrome LEDs and in the same position in the Christmas tree we can have as many colors as we want.

So first of all make sure that you have all you need:

-Arduino Uno Board

-RGB LEDs

-LEDs

-resistors

-Wires

-Soldering iron

You can connect the LEDs as in my diagram and you can use as many as you want connected in parallel

Step 1:

upload un the board the following Arduino code, using Arduino IDE:

/*
RGB LED_BUILTIN */

int redPin = 11;

int greenPin = 10;

int bluePin = 9;

int redPin1 = 3;

int greenPin1 = 5;

int bluePin1 = 6;

//uncomment this line if using a Common Anode LED_BUILTIN

//#define COMMON_ANODE

void setup() {

pinMode(redPin, OUTPUT);

pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);

pinMode(redPin1, OUTPUT);

pinMode(greenPin1, OUTPUT);

pinMode(bluePin1, OUTPUT);

pinMode(LED_BUILTIN, OUTPUT);

}

void loop() {

setColor(255, 0, 0); // red

digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)

delay(1000);

setColor(0, 255, 0); // green

digitalWrite(LED_BUILTIN, LOW);

delay(1000); setColor(0, 0, 255); // blue

digitalWrite(LED_BUILTIN, HIGH);

delay(1000); setColor(255, 255, 0); // yellow

digitalWrite(LED_BUILTIN, LOW);

delay(1000); setColor(80, 0, 80); // purple

digitalWrite(LED_BUILTIN, HIGH);

delay(1000); setColor(0, 255, 255); // aqua

digitalWrite(LED_BUILTIN, LOW);

delay(1000);

setColor(80, 80, 0);

digitalWrite(LED_BUILTIN, HIGH);

delay(1000); setColor(80, 60, 10);

digitalWrite(LED_BUILTIN, LOW);

delay(1000); setColor(10, 40, 60);

digitalWrite(LED_BUILTIN, HIGH);

delay(1000);

setColor(40, 0, 220);

digitalWrite(LED_BUILTIN, LOW); delay(1000); }

void setColor(int red, int green, int blue) {

#ifdef COMMON_ANODE red = 255 - red;

green = 255 - green;

blue = 255 - blue;

#endif

analogWrite(redPin, red);

analogWrite(greenPin, green);

analogWrite(bluePin, blue);

analogWrite(redPin1, red);

analogWrite(greenPin1, green);

analogWrite(bluePin1, blue); }

//feel free to add other Arduino digital pins as output for new LEDs

//enjoy

Holiday Decor

Participated in the
Holiday Decor