#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit duxa=P2^6;
sbit wexa=P2^7;
sbit k1=P1^2;
sbit k2=P1^ 3;
sbit k3=P1^4;
uchar temp,qian,bai,shi,ge;
uint num,a,shu;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void init();
void delay(uint z);
void display(uchar num,uchar qian,uchar bai,uchar shi,uchar ge);
void main()
{
init();
while(1)
{
display(num,qian,bai,shi,ge);
if(k1==0)
{
delay(1);
TR0=0;
delay(1 );
}
if(k2==0)
{
delay(1);
TR0=1;
delay(1);
}
if(k3==0)
{
delay(1);
a=0;
num=0;
TR0=1 ;
delay(1);
}
}
}
void init()
{
num=0;
temp=0xf0;
TMOD=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
EA=1;
ET0=1;
TR0=1;
bai=0;
shi=0;
ge=0;
a=0;
k1=1;
k2=1;
k3=1;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void timer0() interrupt 1
{
TH0=(65536-1000)/256 ;
TL0=(65536-1000)%256;
a++;
if(a==9999)
{
a=0;
num++;
if(num==10)
num=0;
}
shu=a;
qian=shu/1000;
bai =shu%1000/100;
shi=shu%100/10;
ge=shu%10;
}
void display(uchar num,uchar qian,uchar bai,uchar shi,uchar ge)
{
wexa=1;
P0=0xfe;
wexa=0;
P0=0;
duxa=1;
P0=table[num];
duxa=0;
P0=0xff;
delay(1);
wexa=1;
P0=0xfd;
wexa=0;
P0=0;
duxa=1;
P0=table[qian];
duxa=0;
P0=0xff;
delay(1);
wexa=1;
P0=0xfb;
wexa=0;
P0=0;
duxa=1;
P0=table[bai];
duxa=0;
P0=0xff;
delay(1);
wexa=1;
P0=0xf7;
wexa=0;
P0=0;
duxa=1;
P0=table[shi];
duxa=0;
P0=0xff;
delay(1);
wexa=1;
P0=0xef;
wexa=0;
P0=0;
duxa=1;
P0=table[ge];
duxa=0;
P0=0xff;
delay(1);
}
Previous article:51 single chip microcomputer drives 16*16 dot matrix to display happy birthday program
Next article:51 MCU Assembly: Multi-channel Delay Switch
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
- Sentenced to 4 years! Megvii Technology driver attempted to extort 3 million yuan from the chairman but failed
- Why do clocks use 32.768K crystals?
- Problems and Solutions in TMS320F206 Simulation Debugging
- Disassembly of 10 yuan smart bracelet
- Last day! Microchip Live Broadcast | How to solve precision timing challenges in ADAS systems
- [Fudan Micro FM33LG0 Series Development Board Review] Basic Introduction
- MaxplusII advanced use and improvement.rar
- Talking about software architecture from the perspective of history - object-oriented programming (Part 3)
- DCDC input end inrush current problem
- Non-blocking assignment order problem