Colorful luminous glass

Do your own colorful luminous glass.

Inside the bottle is the broken glass and water, so the light will happen diffuse reflection.

You can adjust delay and breathing frequency in program (CYCLE = 660 If 660 is small the frequency is small…) which can complete the change of three kinds of color instead of three kinds of color change at the same time.
This is the program:
#include<reg51.h>
/----------- Define microcontroller pins -----/
sbit LED0=P1^0;
sbit LED1=P1^1;
sbit LED2=P1^2;
sbit LED3=P1^3;
sbit LED4=P1^4;
sbit LED5=P1^5;
sbit LED6=P1^6;
sbit LED7=P1^7;

void Delay(unsigned int t); // Function declaration
unsigned int z,y;
unsigned char n,i;

void main (void)//main function
{
unsigned int CYCLE=660,PWM_LOW=0;// Define the cycle and assign the value

while (1)         //major cycle
{

/-------- The first LED light breathe ---------/
LED2=1;
LED1=1;
LED0=1;
Delay(500);
for(PWM_LOW=1;PWM_LOW<CYCLE;PWM_LOW++)
{
LED1=0;
LED2=0;
LED0=0;
Delay(PWM_LOW);
LED2=1;
LED1=1;
LED0=1;
Delay(CYCLE-PWM_LOW);
}

	LED1=0;
	LED2=0;
	LED0=0;										
	for(PWM_LOW=CYCLE-1;PWM_LOW>0;PWM_LOW--)    
		{
			LED1=0;
			LED2=0;
		   	LED0=0;
		   	Delay(PWM_LOW);
			
			LED1=1;
			LED2=1;
		   	LED0=1;
		  	Delay(CYCLE-PWM_LOW);   			
		}
		for(n=250;n>0;n--)
		      for(i=250;i>0;i--);
			  	for(n=250;n>0;n--)
		      for(i=250;i>0;i--);
			  	for(n=250;n>0;n--)
		      for(i=250;i>0;i--);			
			
			  
}

}
void Delay(unsigned int t)
{
while(–t);

}
I use AT98S52 chip. I use three chips to control three colors of RGB respectively. You can get some SCM at http://kynix.com for newbie.
I feel like AT89S52 single chip microcomputer can only control 1 lamp! If who knows what can control two lights at the same time please tell me!
The white cell is phone battery which makes it no need to drag a long wire!
The minimum system of a single chip microcomputer cannot reduce crystals. 10 uf capacitance should be added directly between the RST and the VCC in reset circuit. Otherwise the single-chip computer works very unstable. I use a patch which you can’t see clearly.
Why I should turn the pin to bend, because of the small version of general-purpose board.
If the general-purpose board is so large that on the glass bottle is not beautiful. Anyway, it can realize the phenomenon.

5 Likes

This topic was automatically closed after 206 days. New replies are no longer allowed.