Interfacing RGB LED with ATtiny85

7,951 views

Introduction

RGB LED has great usage nowadays, usually used for decoration for different occasions. For example, they can use it in stage lighting, at parties, weddings, etc. It is an LED having three terminals, RGB in a color, red, green, and blue which are present. These three LEDs together produce a single-intensity output light, and by adjusting the intensity of the internal single LED, we can get any needed output color light.

The prominent part of this RGB LED is its features. For example, its small size occupies less area or space, it is less toxic, and has greater efficiency. So, in this tutorial, we are going to interface “RGB LED with ATtiny85 Microcontroller”.

PCBWay commits to meeting the needs of its customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests. As one of the most experienced PCB manufacturers in China. They pride themselves to be your best business partners as well as good friends in every aspect of your PCB needs.

Hardware Components

S.noComponentValueQty
1.Atmel MicrocontrollerAttiny851
2.SMD Resistors10k,2201,1
3.SMD LED1
4.SocketCR20321
5.Female Header1
6.2 Pin Connector1
7.Breadboard1

Circuit Diagram

CODE

// Circuits DIY
// For Complete Details Visit -> https://circuits-diy.com  

int red_light_pin= 2;
int green_light_pin = 3;
int blue_light_pin = 4;
void setup() {
  pinMode(red_light_pin, OUTPUT);
  pinMode(green_light_pin, OUTPUT);
  pinMode(blue_light_pin, OUTPUT);
}
void loop() {
  RGB_color(255, 0, 0); // Red
  delay(1000);
  RGB_color(0, 255, 0); // Green
  delay(1000);
  RGB_color(0, 0, 255); // Blue
  delay(1000);
  //RGB_color(255, 255, 125); // Raspberry
  //delay(1000);
  //RGB_color(0, 255, 255); // Cyan
  //delay(1000);
  //RGB_color(255, 0, 255); // Magenta
  //delay(1000);
  //RGB_color(255, 255, 0); // Yellow
  //delay(1000);
  //RGB_color(255, 255, 255); // White
  //delay(1000);
}
void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
 {
  analogWrite(red_light_pin, red_light_value);
  analogWrite(green_light_pin, green_light_value);
  analogWrite(blue_light_pin, blue_light_value);
}

Working Explanation

To interface RGB LED with ATtiny85, first, connect the circuit according to the diagram given above, and upload the above-mentioned code. The circuit will display colors according to the patterns given in the code.

These RGB LEDs follow up on a lot less complex standard. The circuit changes the power on each of the three LEDs, red, green, and blue to create a particular shading blend intensity. For instance, to make a magenta tone, it would wrap the red and blue LEDs up, and the green direct would stay wound down totally. Thus it’s a performance of various powers to deliver various color intensities.

Applications

  • Home and bedroom decorating lightning purpose
  • Outdoor decoration lighting
  • Birthday and wedding decorating
  • In different electronics projects
  • In stage lighting designs.