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
#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
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
{
d0=yin7;
d1=0;
d2=0;
d3=0;
d4=0;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>10)&&(ji<20))//23456789
{
d0=yin6;
d1=yin7;
d2=0;
d3=0;
d4=0 ;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>20)&&(ji<30))//345678910
{
d0=yin5;
d1=yin6;
d2=yin7;
d3=0;
d4=0 ;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
{
d0=yin4;
d1=yin5;
d2=yin6;
d3=yin7;
d4=0;
d5=0;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
{
d0=yin3;
d1=yin4;
d2=yin5;
d3=yin6;
d5=0;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>50)&&(ji<60))//23456789
{
d0=yin2;
d1=yin3;
d2=yin4;
d3=yin5;
d5=yin7;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>60)&&(ji<70))//345678910
{
d0=yin1;
d1=yin2;
d2=yin3;
d3=yin4;
d5=yin6;
d6=yin7;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
{
d0=yin0;
d1=yin1;
d2=yin2;
d3=yin3;
d5=yin5;
d6=yin6;
d7=yin7;
d8=0;
d9=0; d10=
0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>80)&&(ji<90))//12345678
{
d0=0;
d1=yin0;
d2=yin1;
d3=yin2;
d5=yin4;
d6=yin5;
d7=yin6;
d9=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>90)&&(ji<100))//345678910
{
d2=yin0;
d3=yin1;
d4=yin2;
d5=yin3;
d7=yin5;
d8=yin6;
d9=yin7;
d0=0;
d1
=0; d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if((ji>100)&&(ji<110))//345678910
{
d3=yin0;
d4=yin1;
d5=yin2;
d6=yin3;
d8=yin5;
d9=yin6;
d10=yin7;
d0=0;
d1
=0; d2=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
{
d4=yin0;
d5=yin1;
d6=yin2;
d7=yin3;
d9=yin5;
d10=yin6;
d11=yin7;
d2=0;
d3=0;
d12=0;
d0=0;
d13=0;
d14=0;
d15=0;
}
{
d5=yin0;
d6=yin1;
d7=yin2;
d8=yin3;
d10=yin5;
d11=yin6;
d12=yin7;
d0=0;
d1=0;
d2=0;
d3=0;
d4=0;
d14=0;
d15=0;
}
{
d6=yin0;
d7=yin1;
d8=yin2;
d9=yin3;
d11=yin5;
d12=yin6;
d13=yin7;
d0=0;
d1=0;
d2=0;
d3=0;
d4=0;
d14=0;
d15=0;
}
{
d7=yin0;
d8=yin1;
d9=yin2;
d10=yin3;
d12=yin5;
d13=yin6;
d14=yin7;
d0=0;
d1=0;
d2=0;
d3=0;
d4=0;
d6=0;
d15=0;
}
{
d8=yin0;
d9=yin1;
d10=yin2;
d11=yin3;
d13=yin5;
d14=yin6;
d15=yin7;
d0=0;
d1=0;
d2=0;
d3=0;
d4=0;
d6=0;
d7=0;
}
{
d0=0;
d1=0;
d2=0;
d3=0;
d4=0;
d6=0;
d7=0;
d8=0;
d10=0;
d11=0;
d12=0;
d14=0;
d15=0;
}
if(ji>450)
{
TR0=0;
ji=0;
TR0=1;
}
}
}
Previous article:Infrared remote control code microcontroller test program
Next article:89C52 and LCD1602
Recommended ReadingLatest update time:2024-11-15 07:30
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Problems with the 5V3-pin DCDC voltage reference chip
- TI prize live broadcast pre-registration is waiting for you to watch~
- EEWORLD University Hall----Live Replay: Future Perception is Predicted by Me-The Latest Application of Sensors in the Internet of Things
- Design of Power Amplifier Circuit for MSP430F449 Single Chip Microcomputer
- Senior Sales Engineer
- [MM32 eMiniBoard Review] + Reunion with Smart Development Board
- [2022 Digi-Key Innovation Design Competition] Home Smart Dashboard - LVGL transplantation and testing
- 5G system core capability indicators
- The relationship between the four major parameters of RF microwave
- DSP basic experiment: light emitting diode display led.c