Original work LED meteor shower lamp (51 single chip microcomputer program code) product sharing!

Publisher:JoyfulExplorerLatest update time:2015-07-20 Source: 51heiKeywords:LED Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Recently, our company has produced a meteor shower lamp! Now we share it with you! 
 
1. Picture sharing:
 

 2. PCB file sharing:

 
 

 3. Schematic diagram sharing:

 

Four,


   There are only 5 light tubes made above. If you need to add more light tubes, just slightly change the following program. If you increase
the number of light tubes and arrange the light tubes in a circle or square, the effect will be quite awesome.

   This meteor lamp has a diameter of only 1.5 cm and can only be made into 30 cm, 50 cm, 80 cm, 1000 cm, etc.
This thing is mainly for decoration. Technical support: http://www.51hei.com/  All source codes are open below.
Please give us your advice. You can modify the program code at will, but it cannot be used for commercial purposes.

/*Meteor Shower Program Code Author: Hu Qin 2011-12-12
  Single Chip Microcomputer Model: STC11F04 IO Ports 16! Principle:
  Use PWM to simulate meteor shower: divide the brightness level into 8 levels
, and achieve the meteor shower effect by changing the brightness of each group of LEDs.
(Because the meteor shower is bright at the front and gets darker at the back, just like a dragon, dragging its tail over),
download the complete program source code: http://www.51hei.com/f/ledss.rar
*/
#include//MCU header file
#define uchar unsigned char//Word floating type macro definition
#define uint unsigned int//Integer macro definition
#define shudu 3 //LED gradient speed adjustment
uchar yin0 =31;//LED change level adjustment
uchar yin1 =63;//LED change level adjustment
uchar yin2 =95;//LED change level adjustment
uchar yin3 =127;//LED change level adjustment
uchar yin4 =159;//LED change level adjustment
uchar yin5 =191;//LED change level adjustment
uchar yin6 =223;//LED change level adjustment
uchar yin7 =255;//LED change level adjustment
sbit led0=P3^5;//16 IO ports
sbit led1=P3^6;
sbit led2=P3^0;
sbit led3=P3^1;
sbit led4=P3^2;
sbit led5=P3^3;
sbit led6=P3^4;
sbit led7=P3^7;
sbit led8=P1^0;
sbit led9=P1^1;
sbit led10=P1^ 2;
sbit led11=P1^7;
sbit led12=P1^6;
sbit led13=P1^5;
sbit led14=P1^4;
sbit led15=P1^3;
uchar d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15; //variables of each IO port

d1,uchar d2,uchar d3,uchar d4,uchar d5,uchar d6,uchar d7,uchar d8,uchar d9  ,uchar d10,uchar d11,uchar d12,uchar d13)  ; //delay loop } /******************************************************/ / **********
PWM control red, green and blue 3 kinds of lights on and off time *********/ /******************************************************/  void RGBpwm(uchar d0,uchar d1,uchar d2,uchar d3,uchar d4,uchar d5,uchar d6,uchar d7,uchar d8,uchar d9,uchar d10,uchar d11,uchar d12,uchar d13,uchar d14,uchar d15)//3 local variables, some of which are functions with parameters {  if(d0!=0)  {  led0=0;  delay(d0);                      led0=1;//1  }  if(d1!=0)  {  led1=0;  delay(d1);                      led1=1;//1  }  if(d2!=0)  {  led2=0;  delay(d2); //2                     led2=1;  }  if(d3!=0)  {  led3=0;  delay(d3);                      led3=1;//3  }  if(d4!=0)  {  led4=0;  delay(d4);                      led4=1;//4  }  if(d5!=0)  {  led5=0;  delay(d5);                      led5=1;//5  }  if(d6!=0)  {  led6=0;  delay(d6);                      led6=1;//6  }  if(d7!=0)  {  led7=0;  delay(d7);                      led7=1;//7  }  if(d8!=0)  {  led8= 0;  delay(d8);                      led8                      =1;//  8  }  if  (d9!=0)  {  led9=0;  delay  (                     d9);                     led9  =  1;// 9  }  if(d10  !=0)  {  led10=0  ;  delay(                      d10  )  ;  //10                     led10=1;  }  if  (  d11  !  =  0  ;  14                      =  1  ;  }






































































































 if(d15!=0)//15
 {
 led15=0;
 delay(d15);                    
 led15=1;
 }
}[page]
  
/***************************************************/
/************************Main program************************/
/***************************************************/
void main()
{
 TMOD=0x01;
 EA=1;
 ET0=1;
 TR0=1;
 TH0=(65536-56)/256;
 TL0=(65536-56)%256;
 while(1)//Main loop of program
 {
  RGBpwm(d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15);//Call RGBpwm subroutine
 }
}
/*****************************************************/
/*Interrupt service subroutine (control the duty ratio of the red, green and blue LED on and off time)*/
/********************************************************/
void zhong() interrupt 1//interrupt vector bit is 1
{
 uint num;//timer count variable
 uint ji;//brightness level control variable 
 TH0=(65536-500)/256;//assign a value to the high 8 bits of the timer
 TL0=(65536-500)%256;//assign a value to the low 8 bits of the timer
 num++;//automatically increase the timer count by 1
 if(num==shudu)//if the speed variable is equal to the timer counter variable, execute the following curly bracket statement
 {
  num=0;//clear the counter to 0
  ji++;//increase the brightness level control variable by 1
  if((ji>0)&&(ji<10))//Shift the flow.....
  {
 d0=yin7;
 d1=0;
 d2=0;
 d3=0;
 d4=0;
 d5=0;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
  if((ji>10)&&(ji<20))//23456789
  {
 d0=yin6;
 d1=yin7;
 d2=0;
 d3=0;
 d4=0 ;
 d5=0;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>20)&&(ji<30))//345678910
  {
 d0=yin5;
 d1=yin6;
 d2=yin7;
 d3=0;
 d4=0 ;
 d5=0;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>30)&&(ji<40))//4567891011
  {
 d0=yin4;
 d1=yin5;
 d2=yin6;
 d3=yin7;
 d4=0;
 d5=0;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 
 
  if((ji>40)&&(ji<50))//12345678
  {
 d0=yin3;
 d1=yin4;
 d2=yin5;
 d3=yin6;
 d4=yin7;
 d5=0;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
  if((ji>50)&&(ji<60))//23456789
  {
 d0=yin2;
 d1=yin3;
 d2=yin4;
 d3=yin5;
 d4=yin6;
 d5=yin7;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>60)&&(ji<70))//345678910
  {
 d0=yin1;
 d1=yin2;
 d2=yin3;
 d3=yin4;
 d4=yin5;
 d5=yin6;
 d6=yin7;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>70)&&(ji<80))//4567891011
  {
 d0=yin0;
 d1=yin1;
 d2=yin2;
 d3=yin3;
 d4=yin4;
 d5=yin5;
 d6=yin6;
 d7=yin7;
 d8=0;
 d9=0; d10=
 0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 
 

  if((ji>80)&&(ji<90))//12345678
  {
 d0=0;
 d1=yin0;
 d2=yin1;
 d3=yin2;
 d4=yin3;
 d5=yin4;
 d6=yin5;
 d7=yin6;
 d8=yin7;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 
if((ji>90)&&(ji<100))//345678910
  {
 d2=yin0;
 d3=yin1;
 d4=yin2;
 d5=yin3;
 d6=yin4;
 d7=yin5;
 d8=yin6;
 d9=yin7;
 d0=0;
 d1
 =0; d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>100)&&(ji<110))//345678910
  {
 d3=yin0;
 d4=yin1;
 d5=yin2;
 d6=yin3;
 d7=yin4;
 d8=yin5;
 d9=yin6;
 d10=yin7;
 d0=0;
 d1
 =0; d2=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>110)&&(ji<120))//4567891011
  {
 d4=yin0;
 d5=yin1;
 d6=yin2;
 d7=yin3;
 d8=yin4;
 d9=yin5;
 d10=yin6;
 d11=yin7;
 d1=0;
 d2=0;
 d3=0;
 d12=0;
 d0=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>120)&&(ji<130))//56789101112
  {
 d5=yin0;
 d6=yin1;
 d7=yin2;
 d8=yin3;
 d9=yin4;
 d10=yin5;
 d11=yin6;
 d12=yin7;
 d0=0;
 d1=0;
 d2=0;
 d3=0;
 d4=0;
 d13=0;
 d14=0;
 d15=0;
  }
 if((ji>130)&&(ji<140))//678910111213
  {
 d6=yin0;
 d7=yin1;
 d8=yin2;
 d9=yin3;
 d10=yin4;
 d11=yin5;
 d12=yin6;
 d13=yin7;
 d0=0;
 d1=0;
 d2=0;
 d3=0;
 d4=0;
 d5=0;
 d14=0;
 d15=0;
  }
 if((ji>140)&&(ji<150))//
  {
 d7=yin0;
 d8=yin1;
 d9=yin2;
 d10=yin3;
 d11=yin4;
 d12=yin5;
 d13=yin6;
 d14=yin7;
 d0=0;
 d1=0;
 d2=0;
 d3=0;
 d4=0;
 d5=0;
 d6=0;
 d15=0;
  }
 if((ji>150)&&(ji<160))//
  {
 d8=yin0;
 d9=yin1;
 d10=yin2;
 d11=yin3;
 d12=yin4;
 d13=yin5;
 d14=yin6;
 d15=yin7;
 
 d0=0;
 d1=0;
 d2=0;
 d3=0;
 d4=0;
 d5=0;
 d6=0;
 d7=0;
  }
  if((ji>160)&&(ji<450))//Turn off all LEDs and wait for the next meteor...
  {
 d0=0;
 d1=0;
 d2=0;
 d3=0;
 d4=0;
 d5=0;
 d6=0;
 d7=0;
 d8=0;
 d9=0;
 d10=0;
 d11=0;
 d12=0;
 d13=0;
 d14=0;
 d15=0;
  }
  if(ji>450)
 {
 TR0=0;
 ji=0;
 TR0=1;
 }
 }
}

 

Keywords:LED Reference address:Original work LED meteor shower lamp (51 single chip microcomputer program code) product sharing!

Previous article:Infrared remote control code microcontroller test program
Next article:89C52 and LCD1602

Recommended ReadingLatest update time:2024-11-15 07:30

8*8 LED dot matrix display circuit diagram
The following figure is the 8*8 LED dot matrix display circuit diagram. Display a column on the 8X8 LED dot matrix, let it move smoothly from left to right three times, then move smoothly from right to left three times, then move smoothly from top to bottom three times, and finally move smoothly from bottom to top thr
[Analog Electronics]
8*8 LED dot matrix display circuit diagram
80C51 MCU simulation example 100-1 LED flashing
In order to preserve the microcontrollers learned during the holidays, I tried to imitate one example a week, which was also a further study of Proteus. What I am programming today is the LED interval flashing, the time is 1S, and the simulation software is Proteus. /* Main.c file generated by New Project wizard  
[Microcontroller]
80C51 MCU simulation example 100-1 LED flashing
PIC16F877A LED Blinking
Key points:  #define Setbit(y,x) y|=(1 (x)) //setb(p1,2); p12=1;  #define Clrbit(y,x) y&=~(1 (x)) //clrb(p1,2); p12=0;  #define Getbit(y,x) (0x01&(y (x))) //Get a certain bit value  ****************************/  #include pic.h   #include "../head/config.h" //Include your own configuration header file __CONFIG(HS&WDTD
[Microcontroller]
Three steps to calculate the installation cost of LED light strip project
LED light strips are mainly used for decoration. Since many customers are not very familiar with them, they often miss some links when calculating the project quotation, which adds unnecessary costs to themselves. Here is how to calculate the project installation cost of light strips. 1. Number of light strips Calcu
[Power Management]
Analysis of the principle of improving the internal quantum and electro-optical conversion efficiency of LED
  When a forward voltage is applied to the PN junction of an LED , current will flow through the PN junction, and electrons and holes will recombine in the PN junction transition layer to generate photons. However, not every pair of electrons and holes will generate photons. Since the PN junction is an impurity semi
[Power Management]
ON Semiconductor High Efficiency AC-DC LED General Lighting Solutions
    With the trend of energy saving, environmental protection and the rapid growth of global LED lighting, LED bulbs and other products have become almost household names. With the advancement of related technologies, the cost and performance level of LEDs have been greatly improved. ON Semiconductor focuses on using
[Power Management]
ON Semiconductor High Efficiency AC-DC LED General Lighting Solutions
Brief analysis: LED lamp driving power supply design
  For LED lamps to become popular, not only do they need to significantly reduce costs, but they also need to solve the problems of energy efficiency and reliability. Doug Bailey, vice president of marketing at Power Integrations, shared five tips on how to solve these problems: designing efficient and reliable LED l
[Power Management]
Brief analysis: LED lamp driving power supply design
ams and OSRAM lead innovation in light and intelligence for smart driving
With the evolution of digitalization, intelligence, energy conservation, emission reduction, new energy and other major trends, the entire automotive industry has also undergone relatively significant changes. In this industry, automotive lighting and automotive lamps have also undergone a series of corresponding ch
[Automotive Electronics]
ams and OSRAM lead innovation in light and intelligence for smart driving
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号