Arduino Christmas Light

138

Introduction: Arduino Christmas Light

For this project, I am going to use Arduino Leonardo to make a Christmas light. You can use the light for any decorations, on walls, Christmas trees, or any other places. In addition, you can change the light's color from pressing the button on the device, thus, the device can be used in various festivals and holidays. Of course, it can be used in daily life for other purposes.

Video Link:

Supplies

The materials I am using in this project:

1. Arduino Leonardo (you can replace the board with any other types of Arduino boards, Arduino Uno, etc.)

2. 5 LED Light bulbs (any color you would like to use)

3. 5 Resistors (used with the LED light bulbs)

4. A bread board

5. Wires (to connect the LED light and the Arduino board)

6. A container that you think is suitable for the lights

Step 1: Connecting the LED Lights

For this step, you have to place each LED light onto the bread board. Aligning them in a row, with two holes from each other so that it can have more space between each other. Moreover, the right side of the LED needs to be the longer head, on the other hand, the left side will be the shorter head.

Step 2: Connecting the Wires and the Resistors

Then, connect the wires to the LED lights onto the Arduino board. Remember to be aware of the negative and positive positions on the bread board. After connecting the wires, place the resistors as the picture has shown.

Step 3: Upload the Code

After checking the wires', resistors, and the LED lights' places, you can upload the code onto Arduino.

Here is the code :

const int led_count = 12; // Number of leds
const int led_delay = 150; // A delay constant const int led_pins[led_count] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // Pins of the leds

void off() { // All leds off for (int i = 0; i <= led_count; i++) { digitalWrite(led_pins[i], LOW); } delay(led_delay * 5); }

void basic() { // Basic animation for (int j = 0; j <= led_count; j++) { digitalWrite(led_pins[j], HIGH); delay(led_delay); } off(); }

void chaser() { // Chaser animation for (int j = 0; j <= led_count; j++) { digitalWrite(led_pins[j], HIGH); delay(led_delay); digitalWrite(led_pins[j-1], LOW); delay(led_delay); } off(); }

void pairs() { // Pairs animation for (int j = 0; j <= led_count; j++) { digitalWrite(led_pins[j], HIGH); digitalWrite(led_pins[j + 2], HIGH); delay(led_delay * 1.5); digitalWrite(led_pins[j], LOW); digitalWrite(led_pins[j + 2], LOW); } off(); }

void randoms() { // Random leds animation for (int o = 0; o <= 50; o++) { int r = random(1,12); digitalWrite(led_pins[r], HIGH); delay(led_delay); digitalWrite(led_pins[r], LOW); } off(); }

void setup() { for (int i = 0; i <= led_count - 1; i++) { // Initializing the pins pinMode( 2 , INPUT); //改 pinMode(led_pins[i], OUTPUT); } off(); }

void loop() { if (digitalRead( 2 )) { //改 a on/off choice for the users to control when to light basic(); chaser(); pairs(); randoms(); delay(1000); } else { //改 off(); } } //

Step 4: Done!

By finishing the steps above, you are done with your own customized Christmas light! You can use it anywhere and anytime you want!

Video LInk:

https://youtu.be/Fr8KqKn8UAs

Be the First to Share

    Recommendations

    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Organization Contest

      Organization Contest
    • Robots Contest

      Robots Contest

    Comments