LED digital tube is a commonly used display device in the peripheral interface device of single-chip microcomputer. There are two types of display devices, seven-segment tube and Mi tube. The seven-segment tube is commonly used in the laboratory. There are two working modes: common cathode and common anode. The so-called common cathode is to connect the com end of the LED to the ground, and the common anode is to connect the com end to a high level. There are also two driving display modes: static display and dynamic display.
In static display, each digital tube occupies an eight-bit I/O port of the microcontroller, and the lit segment is always on during operation. In this way, the hardware circuit is simple, the programming is simple, but the I/O port of the microcontroller is wasted. The following is a brief demonstration of this driving method.
Connect a digital tube to port P2. The number displayed on the digital tube will automatically increase by one every second, and will be cleared to 0 after adding to 9, and the cycle will continue. In this experiment, the digital tube adopts the common cathode connection method.
The experimental principle diagram is as follows:
The experimental procedure is as follows:
[cpp] view plain copy
#include
#define uchar unsigned char;
#define uint unsigned int;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //Common cathode digital tube data table
uchar a,i,j,z;
void delay(z) //delay sub-function
{
for(j=z;j>0;j--)
for(i=110;i>0;i--);
}
void main() //Main function
{
while(1)
{
for(a=0;a<10;a++) //From 0 to 9, a total of 10 cycles
{
P2=table[a]; //P2 port gets data from the data table
delay(1000); //delay about 1s
}
}
}
The test results are as follows:
Previous article:51 MCU Introduction 5: Digital Tube Display (Dynamic)
Next article:Microcontroller Easy Introduction Part 3: Buzzer
- 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
- Selection method and principle of infrared temperature sensor
- Several gadgets that RF engineers cannot miss
- Application of TPS61046 dual output in optical communication
- MicroPython v2.0 roadmap
- Computer power supply plus current regulation
- PCB design software Protel 99 SE and AD copper-free hole and copper-free slot design
- Why is a bootstrap circuit used in BUCK power chip?
- The states of the terminal device in the TI ZigBee protocol stack involved in the protocol stack
- SPI settings for msp430f149
- Long press and short press based on MSP430F5529 buttons