I recently learned about LED dot matrix and used three methods to display letter groups, namely key control display, automatic change display, and scroll display.
The first
#include"reg51.h"
#include typedef unsigned char u8; typedef unsigned int u16; sbit RCLK=P3^5; sbit SRCLK=P3^6; sbit SER=P3^4; #define GPIP_KEY P1 #define GPIO_DIG P0 u8 keyvalue; u8 code duan[16][8]={{0x00,0x42,0x7e,0x42,0x42,0x3c,0x00,0x00}, //Encode letters {0x00,0x11,0x12,0x14,0xF8,0x14,0x12,0x11}, {0x00,0x00,0x60,0x10,0x0E,0x10,0x60,0x00}, {0x18,0x24,0x22,0x11,0x22,0x24,0x18,0x00}, {0x00,0x42,0x7E,0x42,0x02,0x06,0x00,0x00}, {0x00,0x06,0x61,0x91,0x89,0x86,0x60,0x00}, {0x81,0xFF,0x81,0x60,0x18,0x86,0xFF,0x81}}; u8 code ledwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //Scan array void delay(u16 i) { while(i--); } void keydown() //key function { u8 a; GPIP_KEY=0x0f; if(GPIP_KEY!=0x0f) { delay(1000); if(GPIP_KEY!=0x0f) { GPIP_KEY=0x0f; switch(GPIP_KEY) { case(0x07): keyvalue=0; break; case(0x0b): keyvalue=1; break; case(0x0d): keyvalue=2; break; case(0x0e): keyvalue=3; break; } GPIP_KEY=0xf0; switch(GPIP_KEY) { case(0x70): keyvalue=keyvalue; break; case(0xb0): keyvalue=keyvalue+4; break; case(0xd0): keyvalue=keyvalue+8; break; case(0xe0): keyvalue=keyvalue+12; break; } while((a<50)&&(GPIP_KEY!=0xf0)) { delay(1000); a++; } } } } void hc595sendbyte(u8 dat) //hc595 module definition { u8 a; SRCLK=0; RCLK=0; for(a=0;a<8;a++) { SER=that>>7; dat<<=1; SRCLK=1; _nop_(); _nop_(); SRCLK=0; } RCLK=1; _nop_(); _nop_(); SRCLK=0; } void main() { u8 i; while(1) { keydown(); for(i=0;i<8;i++) { P0=barely[i]; hc595sendbyte(duan[keyvalue][i]); delay(100); hc595sendbyte(0x00); //LED matrix shadow removal } } } Second type: #include"reg51.h" #include typedef unsigned char u8; typedef unsigned int u16; sbit RCLK=P3^5; sbit SRCLK=P3^6; sbit SER=P3^4; #define GPIP_KEY P1 #define GPIO_DIG P0 u8 keyvalue; u8 code duan[7][8]={{0x00,0x42,0x7e,0x42,0x42,0x3c,0x00,0x00}, //letter segment setting {0x00,0x11,0x12,0x14,0xF8,0x14,0x12,0x11}, {0x00,0x00,0x60,0x10,0x0E,0x10,0x60,0x00}, {0x18,0x24,0x22,0x11,0x22,0x24,0x18,0x00}, {0x00,0x42,0x7E,0x42,0x02,0x06,0x00,0x00}, {0x00,0x06,0x61,0x91,0x89,0x86,0x60,0x00}, {0x81,0xFF,0x81,0x60,0x18,0x86,0xFF,0x81}}; u8 code ledwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //Scan segment void delay(u16 i) { while(i--); } void hc595sendbyte(u8 dat) //hc595 module settings { u8 a; SRCLK=0; RCLK=0; for(a=0;a<8;a++) { SER=that>>7; dat<<=1; SRCLK=1; _nop_(); _nop_(); SRCLK=0; } RCLK=1; _nop_(); _nop_(); SRCLK=0; } void main() { while(1) { u8 i,j,t=100; for(i=0;i<7;i++) { while(t--) { for(j=0;j<8;j++) { P0=ledwei[j]; hc595sendbyte(duan[i][j]); delay(100); hc595sendbyte(0x00); //LED matrix shadow elimination } } t=100; } hc595sendbyte(0x00); } } The third #include"reg51.h" #include typedef unsigned char u8; typedef unsigned int u16; sbit RCLK=P3^5; sbit SRCLK=P3^6; sbit SER=P3^4; #define GPIP_KEY P1 #define GPIO_DIG P0 u8 keyvalue; u8 code duan[]={0x00,0x00,0x00,0x00,0x42,0x7E,0x42,0x00, //I 0x41,0x7F,0x41,0x01,0x01,0x03,0x00, //L 0x3C,0x42,0x42,0x42,0x3C,0x00, //O 0x70,0x0C,0x02,0x0C,0x70,0x00, //V 0x7F,0x49,0x49,0x49,0x49,0x00, //E 0x60,0x10,0x0E,0x10,0x60,0x00, //Y 0x3C,0x42,0x42,0x42,0x3C,0x00, //O 0x40,0x7C,0x42,0x01,0x01,0x42,0x7C,0x40 //U }; u8 code ledwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //Scan code segment void delay(u16 i) { while(i--); } void hc595sendbyte(u8 dat)//hc595 module initialization { u8 a; SRCLK=0; RCLK=0; for(a=0;a<8;a++) { SER=that>>7; dat<<=1; SRCLK=1; _nop_(); _nop_(); SRCLK=0; } RCLK=1; _nop_(); _nop_(); SRCLK=0; } void main() { while(1) { u8 i,j,t=30,q=0; for(i=0;i<46;i++) { while(t--) { for(j=i;j<8+i;j++) { P0=ledwei[q++]; hc595sendbyte(duan[j]); delay(100); hc595sendbyte(0x00); //LED matrix shadow removal } q=0; } t=30; } } }
Previous article:51 routines --- led dot matrix
Next article:Use the 51 single chip microcomputer's LED dot matrix to output Happy Birthday
- 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
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Design of analog signal source for remote sensing images with wide spectrum coverage
- DSP Basics--Fixed-point Decimal Operations
- Small Cell Networks and the Evolution of 5G
- Do you know the chip manufacturer of this Bluetooth module?
- ADS1.2 Issues
- Disassembly of isolator
- Which domestic motor drive company do you think is the most promising?
- What should we pay attention to when developing headphone speakers?
- Analysis of Optimized Programming of TMS320C6000 Embedded System
- Record - Implementing USB virtual serial port on STM32 based on RTT