1 LED dot matrix
LED dot matrix is a display device composed of light-emitting diodes. It can be seen everywhere in our daily electrical appliances and is widely used in bus station announcers, advertising screens, etc. The 8*8 dot matrix is usually used more often, and then multiple 8*8 dot matrices can be used to form LED dot matrix display screens with different resolutions. For example, 16*16 dot matrix can be composed of 4 8*8 dot matrices. Therefore, if you understand the working principle of 8*8LED dot matrix, other resolution LED dot matrix display screens are the same. Here we will introduce 8*8LED dot matrix.
working principle:
The 8*8 dot matrix is composed of 64 light-emitting diodes, and each light-emitting diode is placed at the intersection of the row and column lines. When the corresponding row is set to 1 level (the row is connected to the anode of the diode, so it is a high level) and the column is set to 0 level (the column is connected to the cathode of the diode, so it is a low level), the corresponding diode will light up; if you want to light up the first diode, connect the A1 pin to a high level and the K1 pin to a low level, then the first point will light up; if you want to light up the first row, connect the A1 pin to a high level, and (K1, K2, K3, K4, K5, K6, K7, K8) these pins to a low level, then the first row will light up; if you want to light up the first column, connect the K1 pin to a low level, and (K1, K2, K3, K4, K5, K6, K7, K8) to a high level, then the first column will light up.
Next, we will understand its use in depth by displaying a dot and a number on the LED dot matrix.
2 Schematic diagram
① 8*8 LED dot matrix schematic diagram:
② 74HC595 schematic diagram (connect OE to GND at the JOE pin header):
③ MCU schematic diagram:
3 Procedure
① Light up the first point in the upper left corner:
#include "reg51.h" //This file defines some special function registers of the microcontroller
#include typedef unsigned int u16; //declare and define the data type typedef unsigned char u8; sbit SRCLK=P3^6; //Storage register clock pin (data input clock line) sbit RCLK=P3^5; //Shift register clock pin (output memory latch clock line) sbit SER=P3^4; //Serial data input pin /*********************************************************************************** * Function name: Hc595SendByte(u8 dat) * Function : Send one byte of data to 74HC595 * Input : None * Output : None ***********************************************************************************/ void Hc595SendByte(u8 dat) { u8 i; SRCLK=0; // Initialize the data input clock line RCLK=0; // Initialize the output memory latch clock line for(i=0;i<8;i++) { SER=dat>>7; //Send from the highest bit Example: 1111 0000, the highest bit is 1, shift right 7 bits, and finally become 1, so the highest bit is saved dat<<=1; // Shift left to become the second highest bit, continue with the previous example, shift left to become the second highest bit, shift right 7 bits to become the second highest bit SRCLK=1; // From 0 to 1, that is, from low level to high level, the shift register rises, and the data is stored in the shift register _nop_(); _nop_(); SRCLK=0; // Reset pin } RCLK=1; // shift register clock pin plus rising edge, data parallel output _nop_(); _nop_(); RCLK=0; // Reset pin } /*********************************************************************************** * Function name: main * Function : Main function * Input: None * Output : None ***********************************************************************************/ void main() { Hc595SendByte(0x80); // Write 0b10000000 to make the D7 pin output high level P0=0x7f; // Write 0b01111111 to make the P07 pin output low level while(1); } ② Display the number 0 on the dot matrix: #include "reg51.h" //This file defines some special function registers of the microcontroller #include typedef unsigned int u16; //declare and define the data type typedef unsigned char u8; sbit SRCLK=P3^6; //Storage register clock pin (data input clock line) sbit RCLK=P3^5; //Shift register clock pin (output memory latch clock line) sbit SER=P3^4; //Serial data input pin // Define the display position of number 0 u8 LedSeg[]={0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00}; u8 LedPos[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; /*********************************************************************************** * Function name: delay * Function : Delay function, when i=1, the delay is about 10us ***********************************************************************************/ void delay(u16 i) { while(i--); } /*********************************************************************************** * Function name: Hc595SendByte(u8 dat) * Function : Send one byte of data to 74HC595 * Input : None * Output : None ***********************************************************************************/ void Hc595SendByte(u8 dat) { u8 i; SRCLK=0; // Initialize the data input clock line RCLK=0; // Initialize the output memory latch clock line for(i=0;i<8;i++) { SER=dat>>7; //Send from the highest bit Example: 1111 0000, the highest bit is 1, shift right 7 bits, and finally become 1, so the highest bit is saved dat<<=1; // Shift left to become the second highest bit, continue with the previous example, shift left to become the second highest bit, shift right 7 bits to become the second highest bit SRCLK=1; // From 0 to 1, that is, from low level to high level, the shift register rises, and the data is stored in the shift register _nop_(); _nop_(); SRCLK=0; // Reset pin } RCLK=1; // shift register clock pin plus rising edge, data parallel output _nop_(); _nop_(); RCLK=0; // Reset pin } /*********************************************************************************** * Function name: main * Function : Main function * Input: None * Output : None ***********************************************************************************/ void main() { u8 i; while(1) { P0=0x7f; // Initialize port P0 for(i=0;i<8;i++) //8 rows and 8 columns, bit selection is performed while scanning rows, so there are 8 loops in total { P0=LedPos[i]; //Send bit selection data to control P0 port Hc595SendByte(LedSeg[i]); //Send segment selection data to control 74HC595 delay(100); //delay, the speed cannot be observed by naked eyes Hc595SendByte(0x00); //Blank to prevent affecting the next scan } } }
Previous article:STC89C52RC MCU Extra Chapter | 01 - Understanding interrupts, interrupt sources and interrupt priorities
Next article:Practical Analysis of 8051 MCU (Taking STC89C52RC as an Example) | 08 - Matrix Key Driver
- Popular Resources
- Popular amplifiers
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
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- What? Microsoft deliberately lets you install pirated software!
- Power supply overcurrent and overvoltage protection
- Op amp specification notes
- Variable frequency power supply components: What is the main function of the variable frequency power supply filter capacitor?
- Analysis of the application of TVS tube in the design of mobile phone surge protection
- ST FAE Answer: Reference circuit for replacing BlueNRG's balun BALF-NRG-02D3 with discrete devices
- Analysis of embedded real-time operating system uCOS II
- About atsaM E54 fuse position problem
- [RISC-V MCU CH32V103 Review] Using EXIT Interrupt
- Some Misunderstandings of FPGA Learning