arduino christmas tree

Christmas is just around the corner! In this project, we will make a small acrylic LED Arduino Christmas Tree with Arduino Mega and RGB LEDs. We’ll be using ROHM’s temperature sensor and barometric pressure sensor to change the LED colors. It’s easy to build and code the program. It’ll be super fun to decorate your home with this LED Christmas Tree!

 

A guide to how to setup the sensor shield and connect to Arduino was covered in the previous article. If you haven’t already, please refer back to ROHM Sensor Evaluation Kit Overview!

 

The Christmas tree will do the following:

  • Star-shaped RGB LED will change color alternatively (in loop).
  • Two RGB LEDs (top left and right) will change color depending on local temperature (in the example program is set between 22 to 32 degree Celsius.
  • Two RGB LEDS (bottom left and right) will change color depend on local Barometric Pressure (in the example program is set between 1010 to 1020 hPa).

Hardware

 

Software

 

Tools

  • Mini Hacksaw
  • Dremel Rotary Tool
  • Soldering Iron

 

arduino christmas tree

Figure 1. Arduino Mega 2650 (left), Rohm Arduino Shield(right), Rohm sensors(top)

 

arduino christmas tree

Figure 2. RGB LED with common cathode (-)  (left), RGB LED with common anode (+)  (right)

 

arduino christmas tree

Figure 3. Male- female connectors

 

arduino christmas tree

Figure 4. Power supply 12V

Make the base tree from acrylic

To start let’s make the Christmas tree base using acrylic. Draw the tree on a paper that cover the acrylic then use a small hacksaw to cut the acrylic to make the base for the tree (Figure 5).  Next drill holes for the following:

  • Arduino Mega (3x or 4x)
  • Cable through for RGB LEDs (5x)
  • Red LEDs (2×5)

 

Let’s also cut a small star shape using the leftover acrylic (Figure 6) and glue to the tree (use CA or strong glue).

 

arduino christmas tree

Figure 5. Christmas trees base from acrylic.

 

Install LEDs and connectors

Place red LEDs onto the Christmas tree through the drilled holes then solder the wires so that all the red LEDs are connected in parallel. Make sure all the LEDs are correctly positioned so all anode (+) and cathode (-) are separately connected together. Serially solder a 39 Ohm resistor to red LED’s cathode(-). Also solder 2 connectors: Red connector will go to Arduino Pin 24 and brown connector will go to Arduino Pin GND.

 

There are 2 types of RGB LED: RGB LED with common cathode(-) as in Figure 2 (left) and RGB LED with common anode(+) as in Figure 2 (right). Both can be used in this project. The only difference between the two is, for the common cathode you need to connect the (-) pin into Ground(GND) and for common anode, you need to connect the (+) pin into 5V.

To show how to use these 2 types of RGB LEDs, we will use 3 common anode RGB LEDs (RGB LED1, RGB LED2 and RGB LED3) and 2 common cathode RGB LEDs (RGB LED4 and RGB LED5). Attach this 5 RGB LEDs to the Christmas tree using double tape (see Figure 6).

 

arduino christmas tree

Figure 6. Christmas Tree with attached RGB LEDs, red LEDs and connectors

 

You can see the installation (back side) in Figure 7. Lastly, solder all connections between LEDs, wires, and resistor.

 

arduino christmas tree

Figure 7. View from the back

 

Attach connectors to RGB Leds

Next, connect the 3 wires male-female connectors to RGB LED’s pin, each wire to R-pin, G-pin and B-pin. Figure 8 shows which pins in Arduino Mega these wires are connected to:

 

arduino christmas tree

Figure 8. With RGB LEDs connectors

 

Connect 3 parallel wires to RGB LED 1 (+), RGB LED 2(+) and RGB LED 3(+) and the other end to Arduino Pin 5V.

Connect 2 parallel wires to RGB LED 4 (-) and RGB LED 5(-) and the other end to Arduino Pin GND.

 

arduino christmas tree

Figure 9. With all LEDs and connectors

 

Attach Arduino and sensors

Attach 3 hex nut standoff to Arduino Mega as shown below:

 

arduino christmas tree

Figure 10. Arduino Mega with attached hex nut screw standoffs

 

Attach Rohm Shield on top of Arduino Mega (make sure the pins are aligned), then connect the ROHM Temperature Sensor to Analog 2 header and ROHM Barometric Pressure sensors to I2C header on the Rohm Sensor Shield.

 

arduino christmas tree

Figure 11. Arduino Mega with attached Rohm Sensor Shield and two sensors on top

 

The Barometric Sensor work with either 1.8V or 3V, and the Temperature sensor work only with 3V or 5V. So we must set the voltage to 3V by putting the jumper into 3V (Figure 12).

 

For more information on Rohm sensors, please refer back to ROHM Sensor Evaluation Kit Overview.

 

arduino christmas tree

Figure 12. Putting jumper into 3V

 

Remember we drilled the holes for the Mega? Attach the Mega and Rohm Sensor Shield to the Christmas tree using 3 screws.

 

arduino christmas tree

Figure 13. Arduino Mega and Rohm Shield after attached to Christmas tree.

 

Now connect 3 wires cable from RGB LEDs to Arduino pins. Use the following table and Figure 8 as a guide. The program that will be discussed later will use the following pins so make sure the pins match as below.

 

Assignment of pins from RGB LEDs to Arduino:

 

Connection to Arduino RGB R- Pin RGB G- Pin RGB B- Pin
RGB Led 1 Arduino Pin 36 Arduino Pin 34 Arduino Pin 38
RGB Led 2 Arduino Pin 3 Arduino Pin 4 Arduino Pin 2
RGB Led 3 Arduino Pin 6 Arduino Pin 5 Arduino Pin 7
RGB Led 4 Arduino Pin 9 Arduino Pin 8 Arduino Pin 10
RGB Led 5 Arduino Pin 12 Arduino Pin 13 Arduino Pin 11

 

arduino christmas tree

Figure 14. Connect RGB LED’s wires to Arduino

 

 

Then connect 3 parallel wires (from RGB LED (+)) into 5V and 2 parallel wires (from RGB LED(-)) into GND.

Connect others cable from red LED (-) into the other GND pin in Arduino and from red LED (+) into pin 24.

 

arduino christmas tree

Figure 15. Attach other wires to Arduino.

 

 

arduino christmas tree

Figure 16. Zoomed in on the connection

 

Attach the base to make it stand by itself. Now we have finished making of Christmas tree! Figure 17 shows what it looks like when everything is assembled:

 

arduino christmas tree

Figure 17. Complete LED Christmas tree

 

Program to test sensors

Now let’s test the sensors using the following program. This program was developed using two sample programs from ROHM. Basically it reads data from the sensors and print it into serial monitor.

First, download two libraries (BM1383GLV.h and BD1020.h) from this website : http://www.rohm.com/web/global/sensor-shield-support/pressure-sensor  and http://www.rohm.com/web/global/sensor-shield-support/temperature-sensor

Then, copy them into Arduino Library together with other libraries that were already installed before. Next, copy the following program and upload into the Arduino board. Don’t forget to specify “Arduino/Genuino Mega or Mega 2560” in Tools/Board Manager!

 

 

 

When the program runs correctly open the serial monitor and you will see display similar to below:

arduino christmas tree

Upload Final Program

Now we are ready for the final program. This program will do the following:

  • Read barometric and temperature sensors.
  • Set color for RGB LED 1 based on the value of counter (i.e. add 1 to counter on every loop and reset counter to 0 if value > 3).
  • Set color for RGB LED 2 and RGB LED 3 based on temperature reading.
  • Set color for RGB LED 4 and RGB LED 5 based on barometric reading.

 

Next copy the following program into your Arduino IDE, then change the value of temperature and barometric pressure to suite your local environment.

 

Finally check again that assignment of pins match as shown in Table 1 and Figure 8.

When everything is correct upload them into the board.

 

 

If all is good, then run the program. The result should be similar to the video above. In the video, we demonstrate how the electronic Christmas tree works. It shows an increase in temperature by using hairdryer will change the color of RGB LED 2 and RGB LED 3 from green into red and when the temperature is back to normal, it changes the color back to green.

 

I hope you enjoyed this project! Merry Christmas and Happy New Year to you all!

 

arduino christmas tree

Figure 18. Final Christmas Tree (front view)

 

arduino christmas tree

Figure 19. Complete Christmas Tree (side view)

Purnomo Nuhalim
Purnomo Nuhalim
Hailing from Melbourne, Purnomo is a retiree and electronics enthusiast. Currently he is keeping himself busy with various open hardware projects using Arduino and Raspberry Pi. Besides electronics, he is also passionate about aero modelling and astronomy.

Check us out on Social Media