Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe

FOC Light Fountain with RGB Colour Control

By Ashutosh Bhatt February 27, 2022

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

Prototype of 8051 Microcontroller based FOC Light Fountain

Fig. 1: Prototype of 8051 Microcontroller based FOC Light Fountain

Prototype of 8051 Microcontroller circuit controlling 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

Circuit-Diagram-8051-Microcontroller-Circuitry-Used-Controlling-FOC-Light-Fountain

Project Video


Filed Under: Circuit Design

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions.

  • Can anyone please help me with this single board computer?
  • Anyone successfully communicated to the BlueNRG-M0 module on the B-L4S5I-IOT01A board
  • How to Build an Audio Tone Control?
  • Current version of LTspice not working on Windows 11?
  • Addressable Latch in My Logic Project

RSS Electro-Tech-Online.com Discussions

  • Measuring controller current output with a meter
  • KiCad custom symbol definition correct approach
  • restarting this Christmas project
  • Anyone In The US Ordered From AliExpress Recently?
  • My Advanced Realistic Humanoid Robots Project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Posifa sensors improve low-flow accuracy in compact systems
  • Acopian releases low-profile power supplies rated to 900 W
  • Octavo Systems OSDZU-3 REF Development Platform
  • Same Sky adds enclosure design to its audio engineering capabilities
  • Waterproof SMA-to-MHF I LK assemblies introduced by Amphenol RF

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe