#include #include typedef unsigned int u16; typedef unsigned char u8; sbit butt = P3^2; //Independent button, connected to external interrupt 0 sbit RCLK = P3^5; bit SRCLK = P3^6; sbit SER = P3^4; //HC595 chip u8 code led_H[] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; // dot matrix columns u8 code ledL_I[] = {0x00,0x81,0x81,0xff,0xff,0x81,0x81,0x00}; //The set of rows of I u8 code ledL_LOVE[] = {0x30,0x78,0xfe,0x7f,0x7f,0xfe,0x78,0x30}; //Collection of love u8 code ledL_U[] = {0x00,0xff,0xff,0x03,0x03,0xff,0xff,0x00}; //Collection of U u8 flag=0; // Flag flag = 0; void delay(u16 i) //delay function { while(i--); } void HC595(u8 dat) //HC595 chip { u8 a; RCLK = 0; SRCLK = 0; for(a=0;a<8;a++){ SER = that>>7; dat <<= 1; SRCLK = 1; _nop_(); _nop_(); SRCLK = 0; } RCLK = 1; _nop_(); _nop_(); RCLK = 0; } void Int0_init() //Prepare the parameters of external interrupt 0 in advance { EA = 1; IT0 = 1; EX0 = 1; } void main() //Main function { Int0_init(); while(1){ u8 j; switch(flag){ //switch statement case 0:for(j=0;j<8;j++){ HC595(ledL_I[j]); P0 = led_H[j]; delay(100); HC595(0x00); };break; case 1:for(j=0;j<8;j++){ HC595(ledL_LOVE[j]); P0 = led_H[j]; delay(100); HC595(0x00); };break; case 2:for(j=0;j<8;j++){ HC595(ledL_U[j]); P0 = led_H[j]; delay(100); HC595(0x00); };break; } } } void INT() interrupt 0 { if(butt==0){ delay(1000); if(butt==0){//button pressed if(flag<2) flag++; else flag=0; } } } // Status: I LOVE U (one appears each time you click the dot matrix)
Previous article:MCU Example - Digital Tube Movement
Next article:Understanding of interruptions
Recommended ReadingLatest update time:2024-11-16 13:30
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Siemens PLC from Beginner to Mastery with Color Illustrations (Yang Rui)
- Siemens S7-1200-PLC Programming and Application Tutorial (3rd Edition) (Edited by Shi Shouyong)
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Why does the newly soldered STM32 main control board run about 10 times slower than normal after programming?
- [Discussion] There is no place to make money during the seven days of National Day holiday
- Linux-3.14.52 Compiler Reference Manual v2.0
- ESP32 firmware is divided into two versions: ESP-IDF v3.x/4.x
- Two methods of programming TMS320C6748
- Enabling higher-performance front-end radar to make Vision Zero a reality
- Power supply control principle of three-phase fuel pump used in Mercedes-Benz passenger cars
- Review summary: Free review of Fudan Micro FM33LG0 series, Winsilver chip
- ESP32-S2-Saola-1 calculates pi
- DCDC H-bridge circuit, what is the principle of boost and buck?