Schematic diagram:
Keywords:MCU
Reference address:Single chip microcomputer timer T0 counts seconds C51 program + circuit
The c51 microcontroller program is as follows:
#include
#define UCHAR unsigned char
#define UINT unsigned int
UCHAR table[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
FLY counter;
FLY timer;
void inittime(void)
{
timer=0;
contain=0;
TMOD=0X01;
TH0=0X4C;
TL0=0X00;
EA=1;
ET0=1;
TR0=1;
}
void Delay_1ms(UCHAR i) //1ms delay
{
FLY x,j;
for(j=0;j
for(x=0;x<=148;x++);
}
void segdisplay(void)
{
P0 = 0; //Blanking
P2 = 6; //The 7th digital tube displays
P0 = table[(conter / 10)%10]; //Get the tens digit of i here
Delay_1ms(5); //Display the next number after 0.5 seconds delay
P0 = 0; //Blanking
P2 = 7; //The 8th digital tube display
P0 = table[conter % 10]; //Get the unit digit of i here
Delay_1ms(5);
P0=0;
}
void main()
{
inittime();
while(1)
segdisplay();
}
void timer_t0(void) interrupt 1
{
TH0=0X4C;
TL0=0X00;
timer++;
if(timer==20)
{
timer=0;
contain++;
}
if(conter==100)
contain=0;
}
Previous article:51 MCU matrix button circuit diagram + program
Next article:C51 MCU timer T2 countdown program + circuit diagram
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
Guess you like
- Will UWB positioning be as accurate as Beidou?
- Brief Introduction of Non-Magnetic Coil Solution for National Technology Intelligent Water Meter
- What is a Current Transformer? How to Design a Current Transformer?
- Why are the edges of the lines always uneven when connecting manually?
- What are the conditions for program interruption in the figure?
- How is the current transformer used?
- Sensor Basics and Common Terms
- 4412 development board one-click burning QT program to the development board - install ssh
- 【Xiaomeige SoC】Regenerate hps_0.h file after Altera SOC changes Qsys
- About LM2611