How to make a Colorful LED decoration using the ATtiny85 | 20 Patterns | Step by Step

How to make a Colorful LED decoration using the ATtiny85 | 20 Patterns | Step by Step

Hello and welcome back. In this project, we will learn how to make a colorful LED decoration using the ATtiny85 microcontroller. For that, I used 24 LEDs and three shift register ICs to control them. So, we can control all the LEDs using only three pins from the ATtiny85. This is very useful because the ATtiny85 has a small number of pins. I added 20 LED patterns to this project. You can change them or make your own patterns as you like. These patterns make the decoration look more fun and attractive. If you don’t know what a shift register is, please use the link.

To upload the program to the ATtiny85, I used an Arduino UNO board. You can also use a TTL programmer or another Arduino board for this step. Make sure to select the right board and programmer in the Arduino IDE. Also, I designed a rectangular-shaped PCB for this decoration. So, we can place all the components easily, and the final setup looks clean.

Ok, let’s do this project step by step. The required components are given below.

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 PCBs for this project.

  • Click the “Instant Quote” button and upload the Gerber file, which you can download from the link below.
  • Gerber file – Download
  • For this project, I ordered ten Red PCBs. Next, select the build time and shipping method. Finally, click “Save to Cart” and complete the payment.

Step 3

Thirdly, unbox your PCB package.

Step 4

Next, solder all the components onto the PCB.

Step 5

Afterward, connect the shift registers to the IC bases.

Step 6

Now, let’s set up the ATtiny85 microcontroller to upload the program.

  • First, connect it to the Arduino UNO board. Use the circuit diagram below for the connections.
How to make a Colorful LED decoration using the ATtiny85 | 20 Patterns | Step by Step
  • Next, connect the Arduino UNO board to your computer and open the “Arduino ISP” program from the Examples in the Arduino IDE.
  • After that, select the correct board and port. Then, click the Upload button.

Step 7

Afterward, copy and paste the following program into the Arduino IDE. Also, make sure to include the library file given below.

#include <ShiftRegister74HC595.h>//include library

//<number of shiftregisters>object name(data pin,clock pin,latch pin)
ShiftRegister74HC595<3> led(1, 2, 3);

void setup() {
}

void loop() {
  pattern1(3);
  pattern2(3);
  pattern3(3);
  pattern4(3);
  pattern5(3);
  pattern6(3);
  pattern7(3);
  pattern8(3);
  pattern9(3);
  pattern10(3);
  pattern11(3);
  pattern12(3);
  pattern13(3);
  pattern14(3);
  pattern15(3);
  pattern16(3);
  pattern17(3);
  pattern18(3);
  pattern19(3);
  pattern20(3);
}



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 < 24; a++) {
      led.set(a, HIGH);
      delay(50);
      led.set(a, LOW);
    }
    for (int b = 23; b > 0; b--) {
      led.set(b, HIGH);
      delay(50);
      led.set(b, LOW);
    }
  }
}

void pattern3(int a) {
  for (int x = 0; x < a; x++) {
    for (int a = 0; a < 24; a++) {
      led.set(a, HIGH);
      delay(50);
    }
    for (int b = 23; b > 0; b--) {
      led.set(b, LOW);
      delay(50);
    }
  }
}

void pattern4(int a) {
  for (int x = 0; x < a; x++) {
    for (int a = 0; a < 24; a++) {
      led.set(a, LOW);
      delay(50);
      led.set(a, HIGH);
    }
    for (int b = 23; b > 0; b--) {
      led.set(b, LOW);
      delay(50);
      led.set(b, HIGH);
    }
  }
}

void pattern5(int a) {
  for (int x = 0; x < a; x++) {
    for (int a = 0; a < 24; a++) {
      led.set(a, HIGH);
      delay(50);
      led.set(a, LOW);
    }
  }
}

void pattern6(int a) {
  for (int x = 0; x < a; x++) {
    for (int a = 0; a < 24; a++) {
      led.set(a, HIGH);
      led.set(a + 4 , HIGH);
      delay(50);
      led.set(a, LOW);
      led.set(a + 4, LOW);
    }
  }
}

void pattern7(int a) { // Center out
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 12; i++) {
      led.set(11 - i, HIGH);
      led.set(12 + i, HIGH);
      delay(50);
      led.set(11 - i, LOW);
      led.set(12 + i, LOW);
    }
  }
}

void pattern8(int a) { // Edge in
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 12; i++) {
      led.set(i, HIGH);
      led.set(23 - i, HIGH);
      delay(50);
      led.set(i, LOW);
      led.set(23 - i, LOW);
    }
  }
}

void pattern9(int a) { // Alternate ON/OFF
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 24; i += 2) led.set(i, HIGH);
    delay(200);
    led.setAllLow();
    for (int i = 1; i < 24; i += 2) led.set(i, HIGH);
    delay(200);
    led.setAllLow();
  }
}

void pattern10(int a) { // Ping pong group of 3
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 22; i++) {
      led.set(i, HIGH);
      led.set(i+1, HIGH);
      led.set(i+2, HIGH);
      delay(50);
      led.set(i, LOW);
      led.set(i+1, LOW);
      led.set(i+2, LOW);
    }
    for (int i = 21; i >= 0; i--) {
      led.set(i, HIGH);
      led.set(i+1, HIGH);
      led.set(i+2, HIGH);
      delay(50);
      led.set(i, LOW);
      led.set(i+1, LOW);
      led.set(i+2, LOW);
    }
  }
}

void pattern11(int a) { // LED wave (every 4th)
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 4; i++) {
      for (int j = i; j < 24; j += 4) led.set(j, HIGH);
      delay(200);
      led.setAllLow();
    }
  }
}

void pattern12(int a) { // Flash outer LEDs
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 3; i++) {
      led.set(0, HIGH);
      led.set(23, HIGH);
      delay(100);
      led.set(0, LOW);
      led.set(23, LOW);
      delay(100);
    }
  }
}

void pattern13(int a) { // Even forward, odd backward
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 24; i += 2) {
      led.set(i, HIGH);
      delay(30);
    }
    for (int i = 23; i >= 1; i -= 2) {
      led.set(i, HIGH);
      delay(30);
    }
    delay(200);
    led.setAllLow();
  }
}

void pattern14(int a) { // Fill 2-by-2
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 24; i += 2) {
      led.set(i, HIGH);
      led.set(i+1, HIGH);
      delay(100);
    }
    delay(300);
    led.setAllLow();
  }
}

void pattern15(int a) { // Blink from both ends inward
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 12; i++) {
      led.set(i, HIGH);
      led.set(23 - i, HIGH);
      delay(60);
      led.set(i, LOW);
      led.set(23 - i, LOW);
    }
  }
}

void pattern16(int a) { // Snake flicker
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 24; i++) {
      led.set(i, HIGH);
      delay(20);
      led.set(i, LOW);
    }
    delay(100);
  }
}

void pattern17(int a) { // Slow fill then fast clear
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 24; i++) {
      led.set(i, HIGH);
      delay(100);
    }
    for (int i = 23; i >= 0; i--) {
      led.set(i, LOW);
      delay(20);
    }
  }
}

void pattern18(int a) { // Two LEDs skip every 3
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 21; i += 3) {
      led.set(i, HIGH);
      led.set(i + 1, HIGH);
      delay(80);
      led.set(i, LOW);
      led.set(i + 1, LOW);
    }
  }
}

void pattern19(int a) { // Center LED pulsing
  for (int x = 0; x < a; x++) {
    int center = 11;
    led.set(center, HIGH);
    delay(300);
    led.set(center, LOW);
    delay(300);
  }
}

void pattern20(int a) { // Odd-even wave
  for (int x = 0; x < a; x++) {
    for (int i = 0; i < 24; i++) {
      if (i % 2 == 0) led.set(i, HIGH);
    }
    delay(200);
    led.setAllLow();
    for (int i = 0; i < 24; i++) {
      if (i % 2 == 1) led.set(i, HIGH);
    }
    delay(200);
    led.setAllLow();
  }
}
  • Now, select the ATtiny board and the correct port. If you haven’t installed the ATtiny board in your Arduino IDE, please add the following link to the Additional Board Manager URLs and install the ATtiny boards from the Board Manager.
  • https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Step 8

Next, remove the ATtiny85 microcontroller from the breadboard and place it into the 8-pin IC base.

Step 9

Finally, connect the 5V DC power supply to the power terminal. Now you can see the LED patterns running one by one. The full video guide is below. So, we hope to see you in the next project. Have a great day!

Troubleshooting Tips

  • Check all soldering points.
  • Check the power source.
  • Select the correct board and port.
  • Check jumper wire connections.
  • Check the IC connections.

How to make a Colorful LED decoration using the ATtiny85 | 20 Patterns | Step by Step

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *