#include "reg52.h"
typedef unsigned int u16;
typedef unsigned char u8;
//138 decoder pin definition
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
//Digital watch
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
//Delay function
void delay(u16 i)
{
while(i--);
}
void DigDisplay(u16 num)
{
u8 i;
u16 bits,ten,hundreds;
//Get position
bits=num%10;
ten=num/10%10;
hundreds=num/100;
//The first three digital tubes light up
LSA=1;LSB=1;LSC=1;
P0=smgduan[hundreds];
delay(700);
LSA=0;LSB=1;LSC=1;
P0=smgduan[ten];
delay(700);
LSA=1;LSB=0;LSC=1;
P0=smgduan[bits];
delay(700);
}
void main()
{
while(1)
{
u16 n;
//n loops from 0 to 999
for(n=0;n<1000;n++)
{
DigDisplay(n);
}
}
}
Previous article:51 Task 17: The timer controls the digital tube from 00-59, increasing by 1 second
Next article:Experiment 13. The digital tube displays from 0 to 9 (and then 0-9 in a cycle)
- Popular Resources
- Popular amplifiers
- 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)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- 51 MCU library serial port sends a segment of characters and the digital tube receives and displays them (use the serial port debugging assistant to modify the data)
- 【BearPi-HM Micro】Part 4: Familiar with the Openharmomy compilation framework and serial port interactive output
- 50 ways to use TI CC6678 digital signal processor (DSP)
- Share: How to reduce EMI and shrink power supply size with integrated active EMI filters
- Calculation and setting of baud rate of msp430 microcontroller
- What is this device and what does it do?
- NeoPixel NanoRing
- How to optimize the area of FPGA design
- LED screen blanking technology
- Integer division problem