After the circuit is programmed, it can light up a single LED light or realize the function of running lights, marquee lights, etc. (You can write the specific program yourself) Here I have written a C source code to realize the running lights. You can also use your own divergent thinking to make the lights light up as you want... Those who have done it by themselves must have had this feeling: the board they bought has been used over and over again, but every time they come up with something new, and every time they write the code, they are completely immersed in it... The picture below shows what the board looks like when the specific function is realized. Let's take a look!
The code to implement the water lamp:
#include
#include
#define uchar unsigned char //Here "uchar" is used instead of "unsigned char", "uchar" is used to define unsigned character type numbers.
#define uint unsigned int //"uint" is used to define unsigned integers.
void delay(uint);
uchar tmp,i;
void main()
{ tmp=0x7f; //Turn on the 8th light (tmp=0x7f=0111 1111)
P0=tmp;
for(i=0;i<7;i++)
{
tmp=_cror_(tmp,1); //Circularly shift right by 1 bit (tmp=1011 1111), light up the 7th light
delay(500);
P0=tmp;
}
P0=0xfe;
for(i=0;i<7;i++)
{
tmp=_crol_(tmp,1); //Circularly shift left by 1 bit
delay(500);
P0=tmp;
}
}
void delay(z)
{ uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
Previous article:Frequency meter hardware circuit diagram based on AT89C51
Next article:Design of universal controller based on RFID application
Recommended ReadingLatest update time:2024-11-23 21:26
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs