//Crystal oscillator 11.0592 //The light changes gradually from bright to dark under the control of the microcontroller, and it feels like breathing //This example uses a digital tube and an LED light to achieve a breathing effect on the 51hei-5 development board //File download: http://www.51hei.com/f/fxd.rar #include#define uint unsigned int #define uchar unsigned char sbit D1=P0^7; fly sr; flying jf; uchar code table[]={ 0,1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,27, 28,29,30,31,32,33,34,35,36, 37,38,39,40,41,42,43,44,45, 46,47,48,49}; void light(uchar num); void delay(uint z); void main() { //Set the counter //Select counting method 1 TMOD = 0x11; //Write the initial value to the counter TH0 = 0; TL0 = 0; //////////////////// //Operate the microcontroller // Enable CPU interrupt EA = 1; /////////////////// // Enable timer T0 interrupt ET0 = 1; //Start the counter TR0 = 1; //Operation diode P1=0; while(1) { if(sr<50) light(sr); else sr=0; } } //Sub function void light(uchar num) { do not fly; D1 = 0; tme = table[num]; delay(tme); D1 = 1; delay(49-tme); } //Interrupt function void time () interrupt 1 { //Increment the independent variable if (jf<2) { jf++; TH0 =0; TL0 = 0; } if (jf==2) { //Write initial value jf=0; TH0 = 254; TL0 = 254; sr++; } } void delay(uint z) { uint x,y; for(x=10;x>0;x--) for(y=z;y>0;y--); }
Previous article:51 MCU interrupt response and cancellation
Next article:Adjustable clock program based on single chip microcomputer timer
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Automotive External Amplifiers
- Award-winning live broadcast | Firmware upgrade solution for Renesas MCU
- Into space: Solid-state power amplifiers aid space exploration
- Frequency deviation definition and measurement method
- Load Modulation High Efficiency Linear Microwave Circuits—Base Station PA and Doherty
- Compile QT5 application with qt creator
- micropython update: 2021.3
- Show off the Xiaomi mouse I received from the Ti reading activity
- [AutoChips AC7801x motor demo board review] + motor demo board unboxing report and quick new project
- About the problem of L6226 controlling brushless DC motor