Based on C language, a countdown board display from 9 to 0 is realized in 8×8 dot matrix.
There is a 1 second interval between each number, which is implemented using a timer.
#include sbit ADDR0 = P1^0; sbit ADDR1 = P1^1; sbit ADDR2 = P1^2; sbit ADDR3 = P1^3; sbit ENLED = P1^4; code unsigned char image[10][8]={ {0xFF,0xC3,0xDB,0xDB,0xC3,0xDF,0xDF,0xC3}, //When the number 9 is to be displayed, the value of P0 {0xFF,0xC3,0xDB,0xDB,0xC3,0xDB,0xDB,0xC3}, {0xFF,0xC3,0xDF,0xDF,0xDF,0xDF,0xDF,0xDF}, //When the number 7 is to be displayed, the value of P0 {0xFF,0xFB,0xFB,0xFB,0xC3,0xDB,0xDB,0xC3}, {0xFF,0xC3,0xFB,0xFB,0xC3,0xDF,0xDF,0xC3}, {0xFF,0xDB,0xDB,0xDB,0xC3,0xDF,0xDF,0xDF}, {0xFF,0xC3,0xDF,0xDF,0xC3,0xDF,0xDF,0xC3}, {0xFF,0xC3,0xDF,0xDF,0xC3,0xFB,0xFB,0xC3}, {0xEF,0xE7,0xE3,0xE7,0xE7,0xE7,0xE7,0x81}, {0xFF,0xC3,0xDB,0xDB,0xDB,0xDB,0xC3,0xFF} }; void main() { ENLED = 0; //Enable dot matrix ADDR3 = 0; EA = 1; // Enable interrupt ET0 = 1; TMOD = 0x01; //Timer initialization TH0 = 0xFC; TL0 = 0x67; TR0 = 1; while(1); } void InterrupTimer0() interrupt 1 { static unsigned long cnt = 0; //ms count static unsigned char sec = 0; //s count static unsigned char i = 0; //dot matrix row number TH0 = 0xFC; //Reassign the timer to ensure that each time is 1ms TL0 = 0x67; cnt++; if(cnt>=1000) { cnt = 0; sec++; if(sec>9) { sec = 0; } } P0 = 0xFF; //Blanking switch(i) { case 0 : ADDR2 = 0;ADDR1 = 0;ADDR0 = 0;i++;P0 = image[sec][0];break; case 1 : ADDR2 = 0;ADDR1 = 0;ADDR0 = 1;i++;P0 = image[sec][1];break; case 2 : ADDR2 = 0;ADDR1 = 1;ADDR0 = 0;i++;P0 = image[sec][2];break; case 3 : ADDR2 = 0;ADDR1 = 1;ADDR0 = 1;i++;P0 = image[sec][3];break; case 4 : ADDR2 = 1;ADDR1 = 0;ADDR0 = 0;i++;P0 = image[sec][4];break; case 5 : ADDR2 = 1;ADDR1 = 0;ADDR0 = 1;i++;P0 = image[sec][5];break; case 6 : ADDR2 = 1;ADDR1 = 1;ADDR0 = 0;i++;P0 = image[sec][6];break; case 7 : ADDR2 = 1;ADDR1 = 1;ADDR0 = 1;i=0;P0 = image[sec][7];break; default : break; } }
Previous article:51 single chip microcomputer course design - LED dot matrix billboard program design
Next article:MCU Example---Timer Control Dot Matrix Display 0~9
- 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
- Let's take a look at the GNU C __attribute__ mechanism
- i.MX6ULL Terminator uses Yocto file system to develop QT-QT project compilation and testing
- Introduction to low-power Bluetooth technology solutions for lithium battery intelligent protection boards
- Principle and application of LM series precision temperature sensing elements
- Japanese Illustrated Book Series: Illustrated Internet of Things
- [Repost] A brief analysis of common errors in PCB design
- Please help analyze the circuit, the 1500V surge test fails
- Sony employee stole $154 million in public funds and exchanged them for Bitcoin: when it was recovered, it appreciated to over $180 million
- 8-bit, 16-bit and 32-bit MCUs, are more bits better?
- [Evaluation of EVAL-M3-TS6-665PN development board] 3. Power-on test