Here I am presenting very interesting project that can be use as a nice show piece or display item with live colours. The desire colour can be set manually from 7 different RGB (Red-Green-Blue) colour combinations.
FOC light fountain is a made up of hair like small optical fibre cables bunched togather at one side. When light of different colours is given from that side the entire bunch of fibers look like fountain of light. Such show pieces are readily and easily available in gift article shops or show piece item shops.
I have also brought one such piece from market and because I am an engineer (espically an EC engineer) i just open it up to look what is inside and to find out its working. After knowing its simple working, this interesting idea comes into my mind that let us make it this way!!!!! The idea in my mind was to change the colours using volume control type knob (just like in music systems or FM/AM radios) and to display the name of colour on LCD (displaying name of colour is actually for kids so that they may get learn with fun).
So what I did is i took 3 LEDs, one red – one green and one blue. Then I made micro controller AT89C52 based circuit with pot, ADC0804 and LCD and controlled this 3 LEDs to generate different colours and colour combinations by varying pot along with displaying colour name on LCD. So let us see the circuit diagram its working and operation.
Circuit diagram:
The circuit is built using ADC0801, micro controllerAT89C52, LCD, 3 LEDs and few extra components.
· The analog input of ADC (Vin) is connected to slider arm of 1 K pot. The other two terminals are connected with Vcc and Gnd. So as pot is varied the analog voltage at pin is varied from 0 V to Vcc
· The chip select pin (CS) is permanently connected to Gnd to make chip always enable. Analog ground (AD), digital ground (DG), Vin- etc pis are also connected to Gnd
· Reference voltage pin Vref is given Vcc/2 voltage through voltage divider network formed by R3 and R4
· Data pins DB0 – DB7 are connected with port P1 of AT89C52. Control pins RD, WR and INTR are connected to port P3 pins P3.7, P3.6 and P3.3 respectively. The INTR is the output from ADC0801 that is used to generate interrupt for AT89C52
· The data pins of LCD D0 – D7 are connected to port P0. Two control pins Rs and En are connected to port P2 pins P2.7 and P2.6 respectively. Control pin RW is connected to ground to make LCD write always enable. Vee pin is connected to slider of another pot that is used to vary the brightness of LCD
· Three LEDs – Red, Green & Blue are connected to port P2 pins P2.0, P2.1 and P2.2 respectively through current limiting resistors in current sinking mode
· A 12 MHz crystal with two 33 pF capacitors is connected to crystal input pins to provide basic clock signal to micro controller for its working and internal operations
Circuit operation:
The circuit generates 7 different colour combinations
1. Only Red
2. Only green
3. Only blue
4. Red and green
5. Green and blue
6. Blue and red
7. Red green and blue
These combinations are changed as pot is varied (turned clockwise or counter clockwise). As the pot is varied the analog voltage at ADC input pin varies. The micro controller gets the corresponding digital value of this analog voltage through ADC. Micro controller gives control signals (WR and RD) to ADC to convert this analog value into digital. The ADC gives 8-bit digital value that is varying from 0 to 255. The micro controller compares this value with 7 different ranges like 0 – 36, 37 – 72, 73 – 108, … … (the ranges are in multiples of 36 because i have divided 0 – 255 in 7 equal ranges so 255 / 7 ≈ 36). These 7 different ranges correspond to 7 different colour combinations given above. The micro controller turns ON required LED or LEDs as per the value falls within any range and generate the colour. The name of the colour or colour combination is displayed on LCD. As anyone continuously varies the pot from min to max, the micro controller generates all 7 colour combinations one by one.
Softwere program
Here are the photographs of running project
Fig. 1: Prototype of 8051 Microcontroller based FOC Light Fountain
Fig. 2: Prototype of 8051 Microcontroller circuit controlling FOC Light Fountain
Software program:
For complete circuit operation, the software program is written and embedded into internal memory of micro controller. The program performs following tasks
· It controls ADC, sends write/read signals to it and gets digital value
· It compares this digital value with 7 different ranges like 0 – 36, 37 – 72, 73 – 108 etc
· It turns ON particular LED or LEDs to generate colour
· It displays colour name or colour combination on LCD
The program is written in C language. It is compiled using KEIL (IDE) software tool. This software generates HEX file when the program is compiled successfully. This HEX file is downloaded into internal FLASH (EEPROM – memory) of micro controller using EEPROM programmer software and hardware tools.
Project Source Code
###
#include
#include "lcd.h"
#include
#define ON 0;
#define OFF 1;
sbit rs = P2^7;
sbit en = P2^6;
sbit wr = P3^6;
sbit rd = P3^7;
sbit red_led = P2^0;
sbit green_led = P2^1;
sbit blue_led = P2^2;
unsigned int color_flag=0,prev_color_flag=0;
unsigned char data d;
void delay()
{
int p,q;
for(p=0;p<150;p++)
for(q=0;q<1000;q++);
}
void lcddly()
{
int x;
for(x=0;x<1500;x++);
}
void writecmd(unsigned char a)
{
lcddly();
rs = 0;
P0 = a;
en = 1;
en = 0;
}
void writedat(unsigned char b)
{
lcddly();
rs = 1;
P0 = b;
en = 1;
en = 0;
}
void writestr(unsigned char *s)
{
unsigned char l,i;
l = strlen(s);
for(i=0;i
{
writedat(*s);
s++;
}
}
void init_lcd()
{
writecmd(0x3C);
writecmd(0x0F);
writecmd(0x01);
}
void int1(void) interrupt 2
{
rd = 0;
d=P1;
rd=1;
if((d>0) && (d<=36)) {red_led = ON; green_led = OFF; blue_led=OFF; color_flag=1;}
else if((d>37) && (d<=72)) {red_led = OFF; green_led = ON; blue_led=OFF; color_flag=2;}
else if((d>73) && (d<=108)) {red_led = OFF; green_led = OFF; blue_led=ON; color_flag=3;}
else if((d>109) && (d<=144)) {red_led = ON; green_led = ON; blue_led=OFF; color_flag=4;}
else if((d>145) && (d<=180)) {red_led = OFF; green_led = ON; blue_led=ON; color_flag=5;}
else if((d>181) && (d<=216)) {red_led = ON; green_led = OFF; blue_led=ON; color_flag=6;}
else if(d>216) {red_led = ON; green_led = ON; blue_led=ON; color_flag=7;}
}
void display_color()
{
if(prev_color_flag!=color_flag)
{
if(color_flag==1) {writecmd(0x01);writestr("RED color");}
else if(color_flag==2) {writecmd(0x01);writestr("GREEN color");}
else if(color_flag==3) {writecmd(0x01);writestr("BLUE color");}
elseif(color_flag==4)
{
writecmd(0x01);
writestr("RED & GREEN");
writecmd(0xC0);
writestr("colors");
}
else if(color_flag==5)
{
writecmd(0x01);
writestr("GREEN & BLUE");
writecmd(0xC0);
writestr("colors");
}
else if(color_flag==6)
{
writecmd(0x01);
writestr("RED & BLUE");
writecmd(0xC0);
writestr("colors");
}
else if(color_flag==7)
{
writecmd(0x01);
writestr("RED & GREEN &");
writecmd(0xC0);
writestr("BLUE colors");
}
prev_color_flag = color_flag;
}
}
void initialize()
{
P1=0xFF;
P2=0x00;
P3=0xCF;
P0=0x00;
P2=0x0F;
IE=0x84;
}
main()
{
initialize();
init_lcd();
while(1)
{
wr=0;
wr=1;
display_color();
delay();
}
}
###
Circuit Diagrams
Project Video
Filed Under: Circuit Design
Filed Under: Circuit Design
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.