florian
Published

Arduino for Holiday - Christmas Tree Lights

Impress your friends and your family with a your Christmas tree lights with unspeakable amount of colours.

BeginnerProtip1 hour922
Arduino for Holiday - Christmas Tree Lights

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RGB Diffused Common Anode
RGB Diffused Common Anode
×5
LED (generic)
LED (generic)
×3
Wire Cable - By the Foot
OpenBuilds Wire Cable - By the Foot
×13
Resistor 220 ohm
Resistor 220 ohm
×7

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

X-mass

schematics
File missing, please reupload.

X-Mass

be original

x-mass

File missing, please reupload.

x-mass_YFnPdHidfU.jpg

Code

x-mass.ino

Arduino
upload it on the board and have hun
/*
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); 
}

Credits

florian

florian

4 projects • 4 followers
2017 graduate from university of polytechnics bucharest, faculty of automatic control and computer science

Comments