Circuit Diagram
Note: In practice, the 74HC573 circuit of my microcontroller is connected in reverse with the P0 terminal.
138 decoder information: https://pan.baidu.com/s/1COTcutsnMxMSc8tq0M2yVw Password: 1jww
The truth table of 138 decoder:
74HC573 information: https://pan.baidu.com/s/1b5OJXniyd6gODyf_eA_sXA Password: m7zx
If you have studied digital electronics, you can take a quick look at the above. If not, it is recommended that you learn digital electronics before getting in touch with microcontrollers, or you can directly read the following.
process
1. First, you need to know how to correctly light up a digital tube (static display).
The interior of the digital tube is composed of seven strip-shaped LEDs and a small dot LED, and the characters are formed according to the brightness of each tube. Common digital tubes have 10 pins. There are two common terminals, which can be divided into common cathode and common anode according to the wiring form of the internal LED. When in use, the common terminal of the common cathode digital tube is grounded, and the common terminal of the common anode digital tube is connected to the power supply. Refer to the figure below:
By giving each pin a high or low level, the on and off of the digital tube can be controlled. Let's take an example. Take the common cathode digital tube as an example. To make the digital tube display the number 0, as long as the six pins abcdef input a high level, the digital tube can display the number 0. At this time, the hexadecimal is 0011 1111 (dp, g, f, e, d, c, b, a) 0x3f. Send the above 0x3f to the 74HC573 latch, and the latch is sent to the digital tube, which lights up the digital tube. (From: https://blog.csdn.net/fanyuqa/article/details/47395333). This time, a common cathode is used.
2. We have learned how to light up a digital tube. Now we will introduce which of the 8 digital tubes to light up.
This requires the use of a 138 decoder. Among them, G1=vcc, G2A=G2B=0, and the purchased circuit has been connected by default. In the above circuit, ABC are P22, P23, and P24 respectively;
If P22=0, P23=0, P24=1 (0 represents low level, 1 represents high level), that is, 001, the corresponding truth table is 4. That is, the 4th digital tube is selected.
Once you know how to select and light up a digital tube, you can start writing programs.
#include "reg52.h"
typedef unsigned int uint;
typedef unsigned char uchar;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
uchar code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //Display the value of 0~F
void main()
{
LSA=0;
LSB=0;
LSC=0;
P0=smgduan[0];
}
The procedure is relatively simple, but there are two things to note.
1. You cannot directly set P2^2=0;
2. After code+array, the array cannot be changed. https://zhidao.baidu.com/question/121263820.html
Here is a video of a static digital tube, which is quite good: https://pan.baidu.com/s/1I7Gz55NCO_yqopAWOr07QA Password: 3p7r
3. Dynamic digital tubes are based on static digital tubes, but different digital tubes are lit each time. When the interval is very short, the human eye cannot distinguish them and will feel that they are all lit at the same time.
#include typedef unsigned int uint; typedef unsigned char uchar; sbit LSA=P2^2; sbit LSB=P2^3; sbit LSC=P2^4; uchar out[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; void delay(uint num) { while(num--); } void display() { u8 i; for(i=0;i<8;i++) { switch(i) //bit selection, select the digital tube to light up, { case(0): LSA=0;LSB=0;LSC=0; break;//display bit 0 case(1): LSA=1;LSB=0;LSC=0; break;//display the first bit case(2): LSA=0;LSB=1;LSC=0; break;//display the second digit case(3): LSA=1;LSB=1;LSC=0; break;//display the third bit case(4): LSA=0;LSB=0;LSC=1; break;//display the 4th bit case(5): LSA=1;LSB=0;LSC=1; break;//display the 5th bit case(6): LSA=0;LSB=1;LSC=1; break;//display the 6th bit case(7): LSA=1;LSB=1;LSC=1; break;//display the 7th bit } P0=out[i]; //Send segment code delay(100); //Scan after a certain period of time P0=0x00; //Blanking } } void main() { while(1) { display(); } } Dynamic digital tube video tutorial: https://pan.baidu.com/s/1fLopEJvdCpouLziTaSWxmg Password: 7szd
Previous article:51 MCU Introduction - Dot Matrix Display Programming Experiment
Next article:51 single chip microcomputer 38 decoder to realize dynamic digital tube control
Recommended ReadingLatest update time:2024-11-15 15:02
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Guwei LCR819 bridge cannot be tested maintenance record
- MP2459 related circuit solution
- TI Industrial Robots Online Seminar Resource Sharing
- Power Optimized 77GHz Liquid Level Transmitter Reference Design
- [Gifts to give away] STMicroelectronics Power and Discrete Devices (PDSA) Quiz with Prizes!
- Enjoy the Avnet Artificial Intelligence Cloud Exhibition and challenge the 60-day check-in learning and development record!
- Weekly review information~
- msp430fr2311 MCU ADC serial channel sampling
- Altium Designer18 Draw the device and add 3D package, then switch to 3D display, but it does not display
- 【National Technology N32G430】3FFT calculation time