Pages

Wednesday, May 22, 2013

RGB-tiny: RGB Led controlled by ATtiny85

INTRO...

      An RGB Led has two variations. The Common Anode and the Common Cathode. Both of them have 4 pins, 3 of them are the three colors Red, Green and Blue and 1 is the common pin.
Typical 4 pins RGB Led
RGB Pin-Out Schematic
         As shown in the pin-out diagram of the Common Anode (CA) RGB Led, Vcc input goes to pin 1 and the rest are: Red-2, Green-3 and Blue-4. When these three goes LOW, the colors lights up. With the proper combinations we can simulate all the colors on the RGB scale. Furthermore by using the PWM function of Arduino we can adjust the level of each color and create a fading sequence.
 
USING THE ATTINY85...

ATtiny85 Pin-Out
      Here is where ATtiny85 comes in handy. With 3 output PWM pins (0, 1, 2) connected to the RGB Led, and the right program, we have a standalone project that changes the color of the LED.
         The ATtiny85 can be programmed any way you want but a good example of code doing the fading can be found here:


https://docs.google.com/document/d/1q4gRjL1U6obGA82zsZtXF4-3z0zBOeNFGxcobzhEt1E/edit?usp=sharing



THE BOARD…
RGB-tiny board
RGB-tiny side view

         The RGB-tiny board has 1 RGB Led soldered with 3 resistors, connected to an 8-pin chip socket, waiting for the programmed ATtiny85. If we supply the circuit with 5 Volts and slide the On/Off switch, the Led will start the fading circle as the program commands.
         The RGB Led is not diffused witch means that the three colors cannot be seen as one. If you want this to happen you can sand the tip of it and you will then see the colors combined into one.



If you want to buy this board you can get for FREE with ATtinyShield. Check my EBay listing:
You will get:
  • The shield with printed and already etched PCB with color silkscreen on it, and of course the components soldered on it. It will be fully functionable ready to program.
  • An Attiny85 20PU chip for your first experiments.
  • A detailed printed (and pdf) guide (in color) for the connections and the whole programming procedure.
  • The RGB-Tiny board, a small PCB with RGB Led, controlled by an ATtiny85 for your first experiments. With code provided you will be able to fade the Led to all colours or any other programming you want.

9 comments:

  1. I have bought this board and have been playing with the RGB code a little too. What i would like to know is how i just get the individual colours Red Green and Blue to show individually. I want Red for 2 secs of for 2 secs, Green for 2 secs off for 2 secs and Blue for 2 secs off for 2 secs and then back around again. I have tried adjusting the RGB values but just seem to get variations of the colours and not just the solid colours that i want. Can you help?

    ReplyDelete
    Replies
    1. i ve tried that
      try this code as a study case to make yours:

      ======

      // RGB_Tiny Board Testing for Common Anode Rgb Leds
      // with LOW it lgiths up the led and with HIGH it lights off because its INVERTED due to common anode rgb led

      // Defining ATtiny pins with RGB Led pins
      const int redPin = 2;
      const int grnPin = 1;
      const int bluPin = 0;
      int del = 500; // delay

      // Setup for outputs
      void setup()
      {

      pinMode(redPin, OUTPUT);
      pinMode(grnPin, OUTPUT);
      pinMode(bluPin, OUTPUT);

      digitalWrite(redPin, HIGH);
      digitalWrite(bluPin, HIGH);
      digitalWrite(grnPin, HIGH);

      }

      // Loop for fading
      void loop() {
      digitalWrite(redPin, LOW);
      delay(del);
      digitalWrite(redPin, HIGH);
      delay(del/2);
      digitalWrite(bluPin, LOW);
      delay(del);
      digitalWrite(bluPin, HIGH);
      delay(del/2);
      digitalWrite(grnPin, LOW);
      delay(del);
      digitalWrite(grnPin, HIGH);
      delay(del/2);
      digitalWrite(redPin, LOW);
      digitalWrite(bluPin, LOW);
      digitalWrite(grnPin, LOW);
      delay(del);
      digitalWrite(redPin, HIGH);
      digitalWrite(bluPin, HIGH);
      digitalWrite(grnPin, HIGH);
      delay(del/2);
      }

      ====

      Delete
  2. Im trying to program an ATTiny, i have a sketch and run it in the board with Arduino as ISP. If i connect LED to the tiny via the board still connected to the UNO everything is fine. Once i remove the chip and try to use it in a circuit nothing is working. It seems the chip has not been programmed. The Red LED on the ATTiny shield does not light at all, any ideas?

    ReplyDelete
    Replies
    1. did you upload the ArduinoISP to the ATMEGA and after that put a 10 uf capacitor between GND and RST?

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. All sorted now, im not sure what i was doing wrong but i have it sorted, its all rather clever really isnt it :)

    ReplyDelete
  5. To make the LED blink faster, you can also change the clock frequency of the ATtiny85 by selecting a different freq. on the boards menu, and then "burn bootloader" from the arduino tools menu. It doesn't make any permanent changes, so you can use whatever clock speed suits your needs.

    ReplyDelete
    Replies
    1. That's a good trick if you dont want to mess with the code.
      I ll keep it in mind.
      Thanks.

      Delete