DIY Christmas Tree with Lights and Music | Simple Christmas Tree idea

Hello and welcome back! In this project, we will learn how to make an electronic Christmas tree using the ATtiny85. I chose the ATtiny85 because I wanted the design to be small and compact. This project includes 16 SMD LEDs to decorate the Christmas tree with bright, colorful lights. A small buzzer is also added to play a cheerful Christmas tune. You can change it as you like. Also, you can easily power this Christmas tree with a coin battery or other power supply. I used an Arduino UNO board to power up this Christmas tree. Also, I created a Christmas tree shape for the PCB to make the project look unique. For that, I used JLCPCB to manufacture the PCB because they provide high-quality boards at an affordable price. This project is perfect as a decoration or even a small gift during the holiday season.
- What is the Attiny85 – Click on Me
Ok, let’s do this project step by step. The required components are given below.
- ATtiny85 Microcontroller x 1 — Our store / Amazon
- 8 Pin IC socket x 1 — Our store / Amazon
- 0805 Red LED x 3 — Our store / Amazon
- 0805 Green LED x 4 — Our store / Amazon
- 0805 Yellow LED x 4 — Our store / Amazon
- 0805 Blue LED x 5 — Our store / Amazon
- 0805 470 Ohm Resistor x 16 — Our store / Amazon
- 74HC595 shift register x 2 — Our store / Amazon
- 5v Active buzzer x 1 — Our store / Amazon
- DIP slide switch x 1 — Our store / Amazon
- SMD battery holder — Our store / Amazon
- Arduino UNO board — Our store / Amazon
- Jumper wires — Our store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.









Step 2
Secondly, let’s order the Christmas tree PCBs. Follow the instructions below.


- Now, click on the “Instant Quote” button and upload the Gerber file. You can download the file using the link provided below.
- Gerber file — Download
- I ordered five green PCBs. Next, select the build time and shipping options, and then click the “Save to Cart” button.





Step 3
Thirdly, unbox your PCB package.







Step 4
Now, solder the SMD LEDs and resistors using a hot air gun or a hot plate.





Step 5
Next, solder the shift registers and the battery holder.




Step 6
Afterward, solder the remaining components using a soldering iron.




Step 7
Now, connect the Christmas tree to the Arduino UNO board to upload the program. After, connect the Arduino board to the computer.
- RCK — D13
- MISO — D12
- MOSI — D11
- RST — D10






- Now, you need to set up the ATtiny85 board in your Arduino IDE. For that, you can follow this tutorial.
- Afterward, copy and paste the following program into the Arduino IDE.
- Code and Gerber file — Download
#include <ShiftRegister74HC595.h> // Include library
ShiftRegister74HC595<2> led(1, 2, 3); //<number of shiftregisters>object name(data pin, clock pin, latch pin)
#define BUZZER_PIN 4
// Notes for "Jingle Bells"
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
// Jingle Bells melody
int melody[] = {
NOTE_E5, NOTE_E5, NOTE_E5,0, // "Jingle bells"
NOTE_E5, NOTE_E5, NOTE_E5,0, // "Jingle bells"
NOTE_E5, NOTE_G5, NOTE_C5, NOTE_D5, NOTE_E5,0,0,0, // "Jingle all the way"
NOTE_F5, NOTE_F5, NOTE_F5, NOTE_F5,0,0, // "Oh what fun it"
NOTE_F5, NOTE_E5, NOTE_E5, NOTE_E5,NOTE_E5,0,0, // "is to ride"
NOTE_E5, NOTE_D5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_G5,0,0,0, // "in a one-horse open sleigh"
};
// Note durations for the melody
int noteDurations[] = {
4, 4, 4, 8, // "Jingle bells"
4, 4, 4, 8, // "Jingle bells"
4, 4, 4, 4, 4,8,8,8, // "Jingle all the way"
4, 4, 4, 4,8,8, // "Oh what fun it"
4, 4, 4, 4, 4,8,8, // "is to ride"
4, 4, 4, 4, 4,8,8,8, // "in a one-horse open sleigh"
};
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
pattern1(3);
pattern2(2);
pattern3(2);
playMelody();
pattern4(2);
pattern5(3);
pattern6(3);
playMelody();
wavePattern(3);
//breathingEffect(3);
//chasePattern(3);
//heartbeatPattern(3);
//randomBlinkPattern(3);
//strobeEffect(3);
centerOutPattern(4);
randomAllBlink(4);
flashingPattern(4);
playMelody();
}
// LED Patterns
void pattern1(int a) {
for (int x = 0; x < a; x++) {
led.setAllHigh();
delay(300);
led.setAllLow();
delay(300);
}
}
void pattern2(int a) {
for (int x = 0; x < a; x++) {
for (int a = 0; a < 16; a++) {
led.set(a, HIGH);
delay(80);
led.set(a, LOW);
}
for (int b = 15; b > 0; b--) {
led.set(b, HIGH);
delay(80);
led.set(b, LOW);
}
}
}
void pattern3(int a) {
for (int x = 0; x < a; x++) {
for (int a = 0; a < 16; a++) {
led.set(a, HIGH);
delay(80);
}
for (int b = 15; b > 0; b--) {
led.set(b, LOW);
delay(80);
}
}
}
void pattern4(int a) {
for (int x = 0; x < a; x++) {
for (int a = 0; a < 16; a++) {
led.set(a, LOW);
delay(80);
led.set(a, HIGH);
}
for (int b = 15; b > 0; b--) {
led.set(b, LOW);
delay(80);
led.set(b, HIGH);
}
}
}
void pattern5(int a) {
for (int x = 0; x < a; x++) {
for (int a = 0; a < 16; a++) {
led.set(a, HIGH);
delay(80);
led.set(a, LOW);
}
}
}
void pattern6(int a) {
for (int x = 0; x < a; x++) {
for (int a = 0; a < 16; a++) {
led.set(a, HIGH);
led.set(a + 2, HIGH);
delay(80);
led.set(a, LOW);
led.set(a + 2, LOW);
}
}
}
void wavePattern(int a) {
for (int x = 0; x < a; x++) {
for (int i = 0; i < 16; i++) {
led.set(i, HIGH);
delay(50);
led.set(i, LOW);
}
for (int i = 15; i >= 0; i--) {
led.set(i, HIGH);
delay(50);
led.set(i, LOW);
}
}
}
void breathingEffect(int a) {
for (int x = 0; x < a; x++) {
for (int brightness = 0; brightness < 255; brightness++) {
for (int i = 0; i < 16; i++) {
led.set(i, brightness);
}
delay(10); // Adjust delay to control breathing speed
}
for (int brightness = 255; brightness > 0; brightness--) {
for (int i = 0; i < 16; i++) {
led.set(i, brightness);
}
delay(10); // Adjust delay to control breathing speed
}
}
}
void chasePattern(int a) {
for (int x = 0; x < a; x++) {
for (int i = 0; i < 16; i++) {
led.set(i, HIGH);
delay(100); // Delay for speed adjustment
led.set(i, LOW);
}
}
}
void heartbeatPattern(int a) {
for (int x = 0; x < a; x++) {
for (int brightness = 0; brightness < 255; brightness++) {
for (int i = 0; i < 16; i++) {
led.set(i, brightness);
}
delay(5); // Speed of pulse up
}
for (int brightness = 255; brightness > 0; brightness--) {
for (int i = 0; i < 16; i++) {
led.set(i, brightness);
}
delay(5); // Speed of pulse down
}
}
}
void randomBlinkPattern(int a) {
for (int x = 0; x < a; x++) {
int randLed = random(0, 16); // Pick a random LED from 0 to 15
led.set(randLed, HIGH);
delay(random(50, 200)); // Random delay for blink speed
led.set(randLed, LOW);
delay(random(50, 200)); // Random delay for blink speed
}
}
void strobeEffect(int a) {
for (int x = 0; x < a; x++) {
led.setAllHigh();
delay(100); // Strobe on time
led.setAllLow();
delay(100); // Strobe off time
}
}
void centerOutPattern(int a) {
for (int x = 0; x < a; x++) {
for (int i = 7; i >= 0; i--) {
led.set(i, HIGH);
led.set(15 - i, HIGH);
delay(100);
led.set(i, LOW);
led.set(15 - i, LOW);
}
}
}
void randomAllBlink(int a) {
for (int x = 0; x < a; x++) {
for (int i = 0; i < 16; i++) {
if (random(0, 2) == 0) {
led.set(i, HIGH);
} else {
led.set(i, LOW);
}
}
delay(200);
}
}
void flashingPattern(int a) {
for (int x = 0; x < a; x++) {
led.setAllHigh();
delay(100);
led.setAllLow();
delay(100);
}
}
// Play the melody
void playMelody() {
for (int i = 0; i < sizeof(melody) / sizeof(melody[0]); i++) {
int noteFrequency = melody[i];
int noteDuration = 1000 / noteDurations[i]; // Note duration in ms
playTone(noteFrequency, noteDuration);
delay(noteDuration * 0.1); // Pause between notes
}
}
// Generate tones for the melody
void playTone(int frequency, int duration) {
long period = 1000000 / frequency; // Period in microseconds
long halfPeriod = period / 2; // Half the period
long cycles = (long)frequency * duration / 1000; // Total cycles for the duration
for (long i = 0; i < cycles; i++) {
digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(halfPeriod);
digitalWrite(BUZZER_PIN, LOW);
delayMicroseconds(halfPeriod);
}
}
- Now, select the board and port, then click the upload button.





Step 8
Next, remove the Arduino board from the Christmas tree and create a base for it. I used a piece of rigifoam for this, but you can use any other material you prefer.






Step 9
Finally, power up the Christmas tree. I used an Arduino UNO board for this. Enjoy the project! The full video guide is below. We hope to see you in the next project. Have a great day!



Troubleshooting Tips
- Check the soldering connections.
- Check the Arduino uno board connections.
- Verify the ATtiny85 Setup.
- Check the program.
- Select the correct board and port.
- Check the power source.
DIY Christmas Tree with Lights and Music | Simple Christmas Tree idea