The digital tube dynamically and vaguely displays the numbers 1-2-3-4-5-6-7-8. The so-called dynamic display actually means that the digital tube scans continuously. We assign values to the first digit, the second digit, etc. of the digital tube at very short intervals. If the time is short, our eyes cannot see the intervals, and it is just a row of numbers.
Proteus schematic diagram:
Proteus renderings:
code:
#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit duan=P2^0;
sbit wei=P2^7;
uchar code table_wei[]={ //Hexadecimal code of selected display character
0x06,0x5b,0x4f,
0x66,0x6d,0x7d,
0x07,0x7f,0x7f};
uchar code table_duan[]={ //Hexadecimal code of bit selection control
0xfe,0xfd,0xfb,0xf7,
0xef,0xdf,0xbf,0x7f,0x7f};
void delay(uint delay_time);
void main()
{
while(1)
{
uint i;
for(i=0;i<8;i++)
{
wei=1; //Turn on the bit select switch
P0=table_wei[i];
wei=0; //Turn off the bit select switch
duan=1; //Turn on the break select switch
P0=table_duan[i];
delay(20);
duan=0; //Turn off the break select switch
}
for(i=8;i>0;i--)
{
wei=1;
P0=table_wei[i];
wei=0;
duan=1;
P0=table_duan[i];
delay(10);
duan=0;
}
}
}
void delay(uint delay_time) //Delay 1ms subroutine
{
uint x,y;
for(x=delay_time;x>0;x--)
for(y=112;y>0;y--)
{;}
}
Previous article:51 MCU instruction set
Next article:Interrupt (MCU interrupt)
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- 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
- How to install and use pressure transmitter
- The flashing prompt cannot recognize the device. What's going on?
- Model-Based Design and Its Embedded Implementation
- Q&A on Connectivity: Why Wi-Fi 6 Could Be Your Competitive Advantage
- Why do we need to learn transistor circuits when we already have integrated circuits?
- 2. Hardware Introduction and Development Environment Installation
- 【New Year's Festival Competition】+ Watching Lanterns on the Lantern Festival (multiple photos)
- 5G small base stations are under the spotlight: now is the eve of the outbreak
- 【CH579M-R1】+ PWM breathing light
- [Experience] [Free trial of Letuo USB oscilloscope] Comparison test of Letuo USB oscilloscope