Four 8×8 dot matrices are used to form a 16×16 dot matrix. Two decoders are used. Only three characters are set (the character converter can be used to change the character). The buttons control left shift, right shift, pause, and start.
The microcontroller source program is as follows:
/************************************************
16x16 dot matrix Chinese character scrolling display
****************************************************/
#include #define uchar unsigned char #define uint unsigned int sbit LA=P1^0; //138 decoder address selection pin sbit LB=P1^1; sbit LC=P1^2; sbit LD=P1^3; sbit k1=P3^6; //Start or pause button sbit k2=P3^7; //Change direction button bit fx=0; //Scroll direction uint index=0; //column scan index uchar code hztab[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //space 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x04,0x10,0x04,0x20,0x24,0x40,0x24,0xfc,0x24,0xa2,0x24,0x22,0xfd,0x22,0x26, //Old 0x42,0x24,0x42,0x2c,0x42,0x14,0x82,0x24,0x1e,0x44,0x00,0x04,0x00,0x04,0x00,0x00, 0x00,0x00,0xe1,0x3f,0x02,0x00,0x0c,0x00,0xf0,0xff,0x00,0x00,0x00,0x40,0xf8,0x47, // Division 0x00,0x44,0x00,0x44,0xff,0x7f,0x10,0x44,0x08,0x44,0xf0,0x47,0x00,0x40,0x00,0x00, 0x02,0x08,0x44,0x08,0xa8,0x0f,0x10,0xf8,0x68,0x08,0x86,0x0f,0x00,0x00,0x00,0x01, // OK 0x02,0x41,0x01,0x41,0xfe,0x47,0x00,0x49,0x00,0x51,0x00,0x61,0x00,0x01,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //space 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; //==================Function declaration==================== void T0_Init(); //Timer 0 initialization void delayus(uint us); //delay function void keyscan(); //Key scan function //====================Main program===================== void main() { uchar i,j; T0_Init(); //Timer 0 initialization while(1) { keyscan(); //key scan for(i=0;i<16;i++) //16 columns of dot matrix { LA=i&0x01; //Use cascade 138 for column selection LB=i&0x02; LC=i&0x04; LD=i&0x08; j=index+i; //Locate the column to be displayed P0=hztab[j*2+1]; //Send dot matrix data P2=hztab[j*2]; //two bytes in total delayus(100); //delay P0=P2=0x00; //Eliminate } delayus(100); //delay } } //=================Timer 0 Initialization================= void T0_Init() { TMOD=0x01; //Timer 0, working mode 1 TH0=(65536-10000)/256; //initial value of constant TL0=(65536-10000)%256; //10ms timing ET0=1; //Enable timer 0 interrupt EA=1; // Enable general interrupt TR0=0; //Do not start timer 0 yet } //===============Timer interrupt 0 service program=============== void timer0() interrupt 1 { static uchar tick=0; //tick timer TH0=(65536-10000)/256; //Reload the initial value TL0=(65536-10000)%256; //10ms timing tick++; // count if(tick==5) //5 times { tick=0; //clear to 0 if(fx==0)index=(index+1)%64; //If the direction is left, the scan line is increased by 1 else index=(index-1+64)%64; //Otherwise the scan line is reduced by 1 } } //===================Delay function==================== void delayus(uint us) { while(us--); } //=================Key scanning function================== void keyscan() { if(k1==0) //Check if k1 is pressed { delayus(100); //delay to eliminate jitter if(k1==0) //Confirm that k1 is pressed { TR0=~TR0; //Timer start, stop and reverse while(k1==0); //Wait for the button to be released } } if(k2==0) //Check if k2 is pressed { delayus(100); //delay to eliminate jitter if(k2==0) //Confirm that k2 is pressed { fx=~fx; //Direction reversal while(k2==0); //Wait for the button to be released } } }
Previous article:51 single chip microcomputer + 74LS160 frequency meter, the highest frequency can be measured is 10M
Next article:Single chip temperature measurement and control system + accuracy of 0.1℃ + 4-digit common anode digital tube display
- 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
- 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
- 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
- Learn about the future of Wi-Fi 6 / 6E through the Wi-Fi Alliance
- WS2410 high performance and low power consumption 2.4G SOC chip
- Does anyone know what circuit this is and what function it has?
- Two new TI boards
- How to observe the PWM output of DSPF2812 through graph in CCS?
- Improve the clarity of the R329 development board camera
- MSP-EXP430F5529LP Development Board 001-GPIO
- Chip type and model
- Several modes of Bluetooth devices
- Acknowledgements | EEWorld’s 15th anniversary, thank you!