/**
*Function: The dot matrix flows upward to display I Love U -Love is a beautiful heart shape
*Time: March 10, 2014 16:19:14
*Author: Han Zhuzi
*Remarks: Animation display principle: The animation is formed by 32 pictures, one frame is refreshed every millisecond, and one frame changes every 250ms, for a total of 32 frames.
**/
#include
typedef unsigned int uint;
typedef unsigned char uchar;
//74HC138
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
//I Love U modulo encoding
uchar code table[] = {/*width 8, height 40*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//Start all black
0xFF,0xC3,0xE7,0xE7,0xE7,0xE7,0xC3,0xFF,//I
0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7,//heart
0xFF,0x99,0x99,0x99,0x99,0x99,0x81,0xC3,//U
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF//Blanking, remove garbled characters
};
uchar counter = 0, index = 0; //Image refresh index (to refresh 32 images, each with an interval of 250ms)
void timer0_init();
void HC138_init();
void main(void)
{
timer0_init();
HC138_init();
while (1);
}
/********timer0 init**********/
void timer0_init()
{
TMOD |= 0x01; //T1 mode 1
TH0 = 0xFC;
TL0 = 0x67; //Load initial value, timing 1ms
TR0 = 1; //start T0
EA = 1; //Open total interrupt
ET0 = 1; //Open timer T0 interrupt
}
/**********74HC138 init************/
void HC138_init()
{
ADDR3 = 0;
ENLED = 0; // Enable U4
}
/**************timer0 interrupt**************/
void timer0_int() interrupt 1
{
static uchar j = 0; //Used to refresh each frame of the picture, the animation consists of 32 pictures
TH0 = 0xFC;
TL0 = 0x67;//1ms
counter++;//ms++
P0 = 0xFF;//blanking
//Dynamic refresh (refresh each frame)
switch (j)
{
case 0: ADDR2 = 0; ADDR1 = 0; ADDR0 = 0;
break;
case 1: ADDR2 = 0; ADDR1 = 0; ADDR0 = 1;
break;
case 2: ADDR2 = 0; ADDR1 = 1; ADDR0 = 0;
break;
case 3: ADDR2 = 0; ADDR1 = 1; ADDR0 = 1;
break;
case 4: ADDR2 = 1; ADDR1 = 0; ADDR0 = 0;
break;
case 5: ADDR2 = 1; ADDR1 = 0; ADDR0 = 1;
break;
case 6: ADDR2 = 1; ADDR1 = 1; ADDR0 = 0;
break;
case 7: ADDR2 = 1; ADDR1 = 1; ADDR0 = 1;
break ;
default: break;
}
P0 = table[index + j++]; //Dynamically refresh each frame of the picture
if (j >= 8)
{
j = 0;
}
//Change frame
if (counter >= 250)
{
counter = 0;
index++;//Number of frames++
if (index >= 32)
{
index = 0;//Maximum 32 frames of images
}
}
}
Previous article:The digital tube of the single-chip microcomputer displays the number of running lights on.
Next article:MCU write LCD1602 liquid crystal program source code
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Playing with Zynq Serial 41——[ex60] Image smoothing processing of OV5640 camera
- Thank you + thank you EEWORLD community
- Medical electronics popular data download collection
- GaN Power Devices
- PIN diodes for RF circuits explained in detail
- During the fight against the epidemic, we will teach you how to have instruments in your mind without having any in your hands.
- Migrating between TMS320F28004x and TMS320F28002x
- K210 performance test again
- 5G high-frequency board material selection and multi-layer board design requirements
- EETALK: What changes has the epidemic brought about in technology?