#include
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={ //Digital tube encoding without decimal point
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90};
uchar code table1[]={ //digital tube code with decimal point
0x40,0x79,0x24,0x30,
0x19,0x12,0x02,0x78,
0x00,0x10};
uchar shi=12,second,minute;
uint num,num1,num2,num3;
sbit k1=P1^4;
sbit k2=P1^5;
void display();
void keyscan();
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void init()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%6;
EA=1;
ET0=1;
TR0=1;
}
void main()
{
init();
while(1)
{
keyscan();
display();
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%6;
num++;
if(num==20)
{
num=0;
second++;
if(second==60)
{
second=0;
minute++;
}
if(minute>=60)
{
minute=0;
shi++;
}
if(shi>=24)
shi=0;
}
}
void display()
{
P2=0xdf;
P0=table[second];
delay(2);
P2=0xff;
P2=0xef;
P0=table[second/10];
delay(2);
P2=0xff;
P2=0xf7;
P0=table1[minute];
delay(2);
P2=0xff;
P2=0xfb;
P0=table[minute/10];
delay(2);
P2=0xff;
P2=0xfd;
P0=table1[shi];
delay(2);
P2=0xff;
P2=0xfe;
P0=table[shi/10];
delay(2);
P2=0xff;
}
void keyscan()
{
if(k1==0)
{
delay(10);
if(k1==0)
{
shi++;
while(!k1);
}
}
if(k2==0)
{
delay(10);
if(k2==0)
{
minute++;
while(!k2);
}
}
}
Previous article:Design of timing electric fan based on single chip microcomputer
Next article:Design of high-precision thickness measurement system based on single-chip microcomputer
- 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
- Registration for the 2021 STM32 Summit and Fan Carnival online live broadcast has begun!
- BleuNRG-1 one master and multiple slaves master module search interval setting
- How to use iic to make LCD screen display
- Design of MSP430 and MMC/SD card interface
- An Engineer's Guide to Temperature Sensing
- Analysis of Rectification Circuit and Filter Circuit
- Learn more about logic analyzers
- What is the status of lithium battery?
- Method for testing FPGA logic unit based on BIST using ORCA structure
- [TI recommended course] #[High Precision Laboratory] Magnetic Sensor Technology#