In this projects 8 different colors are displayed with the use of a RGB LED. The microcontroller that is used is the ATMega8.
An RGB LED is a LED which has three LED's integrated in one packaging. These LED's have the colors red, green, and blue. Such a LED costs about 1 Euro. With these three colours you can mix to any colour. When using 8-bit PWM a number of 255 * 255 * 255 (= 16581375) combinations can be made, thus the LED can show +/- 16.777 million colours, and 256 different brightnesses. When all the three LED's are at full brightness the color will be white. When they are all off the color will be 'black' in the dark . In this projects 8 different colors are displayed, the colors are controlled by a potmeter. The microcontroller that is used is the ATMega8. See in the below table what colors can be displayed.
Schematic and Build
The RGB LED used here has four leads, one for each color and one for the common cathode(ground). The Red LED operates on a voltage of 1.8 V, Green needs 3.8 V, and the Blue LED needs also 3.8 V. Each LED draws 20mA current, so the maximum current consumption is 60mA.
The circuit is very simple.The RGB LED is hooked up to the outputs on PB0, PB1 and PB2 of the ATMega8 microcontroller.
Resistors R1, R2, and R3 act as current-limiting resistors for red, blue, and green LEDs, respectively, and are 150 Ohms each to limit the current to 20mA.
The RGB LED and the resistors are placed on a breadboard and connected to the ATMega328 board.
A tea light cover can be used for proper mixing and diffusing of the three colors.
|1||Hyperflux RGB LED|
You can buy the ATMega328 board at www.bizztronix.net
The code for the fading LED is written in C with the WINAVR C-Compiler. The code runs on a clock source of 16Mhz. You can copy and paste the text file into the WINAVR C-compiler.
// program name: mood lamp
#define F_CPU 16000000UL
// main program
int main (void)
Things to Do
- Use PWM to show more colors.