Assuming you have learned the static display of digital tubes, we know that six digital tubes can only display the same symbol at the same time.
It is common to see several digital tubes that can display different numbers at the same time, such as clocks, etc. This is the topic to be discussed next - dynamic display of digital tubes.
Let’s look at an example:
1 #include
2 #define uint unsigned int
3 #define uchar unsigned char
4 uchar code table[] = {
5 0x3f,0x06,0x5b,0x4f,
6 0x66,0x6d,0x7d,0x07,
7 0x7f,0x6f,0x77,0x7c,
8 0x39,0x5e,0x79,0x71};
9 sbit WELA = P2^7;
10 sbit DULA = P2^6;
11 void delay(uint);
12
13 void main()
14 {
15 while(1)
16 {
17 WELA = 1; //Let the first digital tube display 1
18 P0 = 0xfe;
19 WELA = 0;
20 P0 = 0xff; //Eliminate shadow
21 DULA = 1;
22 P0 = table[1];
23 DULA = 0;
24 delay(500);
25
26 WELA = 1; //Let the second digital tube display 2
27 P0 = 0xfd;
28 WELA = 0;
29 P0 = 0xff;
30 DULA = 1;
31 P0 = table[2];
32 DULA = 0;
33 delay(500);
34
35 WELA = 1; //Let the third digital tube display 3
36 P0 = 0xfb;
37 WELA = 0;
38 P0 = 0xff;
39 DULA = 1;
40 P0 = table[3];
41 DULA = 0;
42 delay(500);
43
44 WELA = 1; //Let the fourth digital tube display 4
45 P0 = 0xf7;
46 WELA = 0;
47 P0 = 0xff;
48 DULA = 1;
49 P0 = table[4];
50 DULA = 0;
51 delay(500);
52
53 WELA = 1; //Let the fifth digital tube display 5
54 P0 = 0xef;
55 WELA = 0;
56 P0 = 0xff;
57 DULA = 1;
58 P0 = table[5];
59 DULA = 0;
60 delay(500);
61
62 WELA = 1; //Let the sixth digital tube display 6
63 P0 = 0xdf;
64 WELA = 0;
65 P0 = 0xff;
66 DULA = 1;
67 P0 = table[6];
68 DULA = 0;
69 delay(500);
70 }
71 }
72
73 void delay(uint ms) //delay function
74 {
75 uint i;
76 for(; ms > 0; ms --)
77 {
78 for(i = 114; i > 0; i --)
79 {
80 }
81 }
82 }
This code is not difficult to understand. In the while() loop, first the first digital tube displays 1, delays 500ms, then the second digital tube displays 2, delays 500ms, and so on.
After compiling this code, download it to the experimental board and observe it to see the expected phenomenon.
Next, shorten the delay after each digital tube lights up to 100ms, that is, delay(100);. Compile and download, and you can see that the speed of digital tube display changes is much faster.
Shorten it to 10ms again, compile and download, now you can vaguely see the numbers 123456 displayed on the 6 digital tubes at the same time, but they are flickering.
Continue to shorten it to 1ms, compile and download, and now the six digital tubes will clearly display 123456.
I think everyone should understand the concept and principle of dynamic display. The so-called dynamic display is to send font codes to each digital tube in turn, but the time is very fast, so that the human eye cannot feel it.
They are displayed one by one in turn.
Previous article:Introduction to MCU: Flowing Lights
Next article:51 MCU memory problem
Recommended ReadingLatest update time:2024-11-23 04:44
- 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
- Transplantation of uC/OS-II on ADSP-BF531
- Enable dynamic power management for embedded devices
- Overview of air conditioning automatic control system 2
- Realization of Simple Single Chip Microcomputer Calculator
- See how many PA posts have been viewed in the forum
- 【PLC based on IoT】---Testing RPI-400 performance based on AI
- Commonly used transistors, triode data
- Are old tools better? Or are you just lazy?
- Smart car based on ESP32 road sign recognition
- Regarding the issue of isolated communication: