How to RGB LED Interfacing with ATtiny85 Microcontroller

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”.


JLCPCB is the foremost PCB prototype & manufacturing company in china, providing us with the best service we have ever experienced regarding (Quality, Price Service & Time).PCB Prototype for 5$

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);
}