/* Name: Button control 8X8LED dot matrix display
Graphics
Note: Each time K1 is pressed, 8X8LED
The dot matrix screen displays different graphics in a cycle.
This example uses both external interrupts and timers.
Time interruption.
*/
#include
#include
#define uchar unsigned char
#define uint unsigned int
//Graphic code to be displayed
uchar code M[][8]=
{
{0x00,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x00}, //Figure 1
{0x00,0x38,0x44,0x54,0x44,0x38,0x00,0x00}, //Figure 2
{0x00,0x20,0x30,0x38,0x3c,0x3e,0x00,0x00} //Figure 3
};
uchar i,j;
//Main program
void main()
{
P0=0xff;
P1=0xff;
TMOD=0x01; //T0 mode 1
TH0=(65536-2000)/256; //2ms timing
TL0=(65536-2000)%256;
IT0=1; //Falling edge trigger
IE=0x83; //Enable timer 0 and external 0 interrupts
i=0xff; //The initial value of i is set to 0xff, and it will start from 0 after adding 1
while(1);
}[page]
//T0 interrupt controls the dot matrix screen display
void Show_Dot_Matrix() interrupt 1
{
TH0=(65536-2000)/256; //Restore initial value
TL0=(65536-2000)%256;
P0=0xff; //Output bit code and segment code
P0=~M[i][j];
P1=_crol_(P1,1);
j=(j+1)%8;
}
//INT0 interrupt (timer is started by keyboard interrupt)
void Key_Down() interrupt 0
{
P0=0xff;
P1=0x80;
j=0;
i=(i+1)%3; //i takes values from 0, 1, 2, because only 3 graphics are needed
TR0=1;
}
Previous article:Microcontroller C language programming: doorbell designed with timer
Next article:Microcontroller C language programming: 8X8LED dot matrix display digital
- Popular Resources
- Popular amplifiers
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- 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)
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
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- Program burning failed
- What op amp circuit is this?
- Serial port idle interrupt cannot be cleared - Solved
- Low power startup (smart toilet development record)
- Share msp430ADC program
- Are there any companies that provide foreign cloud services and APP custom development?
- Live broadcast with awards: When intelligence meets industry, how can technology be implemented?
- [Free Trial] Revolutionize HMI! TI's latest MSP430 development board combination kit, try it out
- How to select the parameters of the RCD circuit resistor in the power supply circuit?
- TI Industrial Month Season 2 - Deep Learning of Technical Solutions