Tuesday 8 February 2022

Christmas Tree using Arduino


Hello Geeks, I hope you all are doing great and enjoying your festive seasons. This time, we have come up with a new project which will make your festival a bit brighter so here comes a Christmas tree.

It is said that Christmas is the center of all the celebrations. Did you guys know the scientist who discovered the light bulb, Thomas Edison and his friends were the first to put up the light bulbs on the Christmas tree, and here we are going to keep that tradition forward? Well, it’s time to gear up for the next season of Christmas being tech-savvy. Hence we have decided to brighten up a Christmas tree with the usage of Arduino Uno and LEDs in real life.

Software to Install:

To make our festival a little safer, we will first make our Christmas tree in the simulation and for that, we will use the Proteus simulation software. Making it in the simulation will give us a good understanding of how it is going to work, and how we are about to design the Christmas tree such as the placements of lights and lighting patterns.

Proteus is a simulation tool for electronic projects. In this software, we can make approximately every type of electronic circuit and run the working simulation. It will show the real-time working simulation of the circuit and errors as well if any occurs.

It has a large database of mostly all types of electronic components but still, for some, we have to install libraries. In this project, we are using Arduino UNO and it is not pre-installed so we have to download it first.

Project Overview:

Following components will be required to design our Christmas Tree

  • Arduino UNO – It works as the main controller in the project. We have used this to make different types of lighting patterns and using this, we will have a scope to make interesting lighting effects.
  • LEDs – We will need LEDs for our Christmas tree. We have used different colors of LEDs to make the matrix shape circuit for the Christmas tree.

Components required:

  • Arduino UNO
  • Different colors of LEDs

Components Details:

Arduino UNO

  • Arduino UNO is an open-source development board that we will use in this project.
  • There are many types of Arduino development boards available but as per our requirement, we will be using Arduino UNO.
  • It uses the ATMega328P processor.
  • This microcontroller has a RISC-based architecture.
  • It has 32KB flash memory, 2KB of SRAM and 1 KB of EEPROM.
  • Talking about the communication peripherals, it has 1 SPI, 1 I2C and 1 UART on board.
  • It comes with 6 individual PWM channels and 6 channels of ADC.
  • There are 14 digital pins starting from D0-D13 and 6 analog pins starting from A0-A5 in this.
  • D10-D13 can be used for digital I/O and SPI communication pinouts.
  • A4 and A5 can be used for analog I/O and I2C communication pins.
  • To power the Arduino, we can use the USB or Vin pin of the Arduino UNO board.

Note – It is recommended to disconnect any connection which is connected with the D0 and D1 pin of Arduino UNO before uploading the code otherwise it will cause issues in communication with the Arduino UNO and there can be an error for the same.

LEDs

  • In this project, we have used different colors of LEDs for our Christmas tree.
  • LED stands for light-emitting diode.
  • It is one of the most efficient light sources compared to all other types of lights or bulbs.
  • They are used mostly in all types of electronics projects such as display, indicators or works as a light source.
  • Due to the long range of applications, LEDs come in a variety of shapes and colors.
  • There are two poles for connecting it, one is short and the other one is longer.
  • Talking about the connection, the longer side pole will be connected to positive voltage and the shorter side will be connected to the ground.
  • As LED is a type of diode, the current will flow in only one direction. In case, if we connect the wiring incorrectly, it will not work.
  • But still, if we have connected the LED wrong, no need to worry, just flip it over.

Mostly it has not been damaged yet.

  • LEDs come in different voltage working ranges but here we have used 5v operating

Circuit Diagram and Working:

Now let’s start with the circuit diagram of our project. The first step would be to import all the components to the workspace of Proteus software.

We will be using one Arduino UNO for controlling the LEDs and six different colors of LEDs. Here we will make 6 rows and 6 columns of LEDs for our Christmas tree, so we will be using 6 Aqua color LEDs, 6 Green color LEDs, 6 Orange color LEDs, 6 White color LEDs, and 6 Yellow color LEDs.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • After importing all the components to the workplace, it’s time to start connecting them.
  • We will use 6 pins of Arduino UNO for rows and 6 pins for columns. As we know, Arduino UNO has 14 digital pins but as suggested we should not connect any connections with D0 and D1 pins.
  • We will connect from D2 to D7 with the rows and D8 to D13 for columns.
  • While connecting the LEDs, we must be very careful in case, if we connect any wrong terminal or any wrong connection, our whole tree will not work because all of them are connected in series with each other and that is the drawback of series connection.
  • In case any connection is loose or wrong then all of the connected components will not work.
  • Keeping this in mind, when we will use the real components, make sure all the LEDs are working fine otherwise we will not get the desired output.
  • Don’t leave any loose connections or hanging wires.
  • It would be easy if we would connect it in steps therefore we will divide it into three steps.
  • First, connect all LEDs and make a 6×6 matrix. For connecting those we can use the simple twisted copper wires.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • While connecting the LEDs, mind the terminals.
  • Now we will connect the column pins.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • After connecting the pins, we will connect the row pins.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • We have divided the connections in different pictures so that it would be easy to understand.
  • After completing all the connections, our circuit will look like as shown in the picture below.
  • Here, we have adjusted the wires, so that it will be in shape as the Christmas tree.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • After completing the connections, there may be a doubt about the working of this circuit.
  • It is a little tricky, we have to make sure from the coding side that whenever we want to glow any LED, its ground terminal should be logic LOW and the positive terminal should be logic HIGH.

Arduino Coding:

After the connection of the circuit, let’s start to code our Christmas tree:

  • For writing the code, we will be using the Arduino IDE.
  • In this application, we will not require any external library.
  • So our code will be divided into three parts: first declaration of variables, pin definition and setup and the last main application logic.

Code declaration

  • First, declare two arrays for rows and columns.
  • In those arrays, we will store assigned pins for each row and column.
  • As we are using D8 to D13 for columns, that will be stored in the “column” array and D2 to D7 for rows, similarly, that will be stored in the “row” array.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

Void setup function

  • This is one of the most important functions as per the structure of the Arduino sketch.
  • As we are using the GPIO pins to control the LEDs, we will set the pin modes of LEDs to be in output mode.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

● We have declared all the row and column pins in the output modes.

Void loop function

  • In this function, we will write our main application code for our Christmas tree.
  • Here we will write the interesting patterns to glow the LEDs of the tree.
  • While making patterns, we only need to focus on two points, first, if we want to glow LEDs sequentially from rows, in this case, set all the pins of the column to logic HIGH state and if we want to glow the LEDs sequentially from columns then we need to set all the row to logic LOW state.
  • Keeping the above-mentioned points, we can glow any pattern on our tree.
  • For blinking the LEDs in a row-wise direction. We have to set all the column pins to HIGH state and then toggle the rows pin to HIGH-LOW.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • For blinking the LEDs in a column-wise direction. We have to set all the row pins to LOW state and then toggle the column pins to HIGH-LOW.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • To turn off all the LEDs, either set all the pins of columns and rows to logic HIGH or set all the pins of columns and rows to logic LOW.
  • To turn off the LEDs by setting all column and row pins to a HIGH state.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • To turn off the LEDs by setting all column and row pins to LOW state.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • We can use either of the above-mentioned logic depending upon the next pattern.
  • Using these simple logics, we can write various patterns.
  • Here in this code, we have written some interesting patterns that would be easy to understand while running the code.

After completing the development side of the Christmas tree, it is time to test it.

Results and Working:

  • As we have successfully completed the coding and the wiring part of our project, let’s start the real fun of running it.
  • In the Proteus, to run any application code, it requires a hex file of the application code.
  • First of all, we need to generate the binary or hex file of our application code using the Arduino IDE.
  • To generate the hex file, we need to go to the toolbar and then click on the “Sketch” option. Thereafter click on the “Export compiled binary”.
  • After that, it will compile the code and a hex file will be generated.
  • Now add this hex file to the Proteus project.
  • To do so, click on the Arduino UNO module and go to the “Program File” option, then browse to the folder containing the hex file.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

  • Now we are all ready to test our project.
  • Click on the “Play” button in the Proteus software.
  • As per our code, first, all the LEDs will blink column-wise, after every 100 milliseconds of delay.
  • Then all the LEDs will blink row-wise similarly after every 100 milliseconds of delay.
  • After that, all the LEDs will be off and it will start glowing in the column-wise pattern from both sides towards the center.
  • Thereafter, it will start glowing from the center towards the sides.
  • Each row will glow and after that, all the LEDs will be off, thereafter each will blink sequentially.
  • The working logic of this circuit is pretty simple. We just have to maintain the appropriate switching of the pins.
  • Using the same we can have different types of interesting patterns.

Christmas Tree simulation, Christmas Tree using arduino, Christmas Tree project with arduino, Christmas Tree in proteus, Christmas Tree proteus simulation, Christmas Tree project download, Christmas Tree arduino code

Here is the working demo of our Christmas Tree

I hope we have covered all the points related to this project and you have enjoyed reading it. We can use this with the real component and decorate the Christmas tree or we can use some cardboard and insert the LEDs on them in the same way.

If you have any doubts regarding the project. And we will be glad to read about how you made your Christmas tree using this project and if you try any interesting new patterns with it, please let us know in the comment section.

Merry Christmas.

The post Christmas Tree using Arduino appeared first on The Engineering Projects.



No comments:

Post a Comment