Use timer 0 interrupt to control 8x8 dot matrix screen to shift left in a loop
#include #include typedef unsigned char u8; typedef unsigned int u16; sbit SRCLK=P3^6; sbit RCLK=P3^5; sbit SER=P3^4; u16 i,k; u16 time; u8 code ledduan[][8]={{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24}, {0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x6c}, {0x00,0x00,0x00,0x00,0x00,0x24,0x6c,0xff}, {0x00,0x00,0x00,0x00,0x24,0x6c,0xff,0xff}, {0x00,0x00,0x00,0x24,0x6c,0xff,0xff,0x6c}, {0x00,0x00,0x24,0x6c,0xff,0xff,0x6c,0x24}, {0x00,0x24,0x6c,0xff,0xff,0x6c,0x24,0x00}, {0x24,0x6c,0xff,0xff,0x6c,0x24,0x00,0x00}, {0x6c,0xff,0xff,0x6c,0x24,0x00,0x00,0x00}, {0xff,0xff,0x6c,0x24,0x00,0x00,0x00,0x00}, {0xff,0x6c,0x24,0x00,0x00,0x00,0x00,0x00}, {0x6c,0x24,0x00,0x00,0x00,0x00,0x00,0x00}, {0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00},}; u8 code ledwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; void delay(u16 i) { while(i--); } void timer0init() { TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; ET0=1; TR0=1; EA=1; } void Hc595SendByte(u8 dat) { u8a; SRCLK=0; RCLK=0; for(a=0;a<8;a++) { SER=dat>>7; dat<<=1; SRCLK=1; _nop_(); _nop_(); SRCLK=0; } RCLK=1; _nop_(); _nop_(); RCLK=0; } void main() { timer0init(); { while(1) { for(i=0;i<8;i++) { P0=ledwei[i]; Hc595SendByte(ledduan[k][i]); delay(50); Hc595SendByte(0x00); } } } } void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; time++; { if(time>=5) { k++; time=0; } if(k>12) { k=0; } } }
Previous article:51 single chip microcomputer project design: ultrasonic-based garage parking system and parking space detection
Next article:51 MCU external interrupt 0 controls the LED on and off
- 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
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- Recommended one: [Lingsheng] MCU code automatic generator (automatic programming tool)
- Learning 3D visualization scene hierarchy from scratch (1)
- What are the differences and connections between compilers and integrated development environments?
- [RISC-V MCU CH32V103 Review] ---Advanced Wiki---Practical debugging methods
- LLC resonant converter classic literature or books, personal test feedback!
- How to use current transformer to measure three-phase electricity?
- When AD is routed, are there grid lines? Are there solid lines?
- Overview of Short Range Wireless Communication Technology
- [HPM-DIY] openmv for hpm6750 repository open source
- I heard that RISC-V is a big hit now?