#include "main.h"
//define variables
unsigned char temp = 0xfe;
unsigned char KEY_NUM = 0;
unsigned char Display_word[4][4] = {
0x00,0x48,0x2A,0x8E,0xFB,0x0E,0x2A,0x48, //亲
0x0C,0x1E,0x3E,0x7C,0x7C,0x3E,0x1E,0x0C, //心
};
//********************************************************
//Main function
//********************************************************
void main()
{
unsigned int i;
unsigned char j,k;
while(1)
{
for(i = 0 ; i < 1000 ; i++)
{
temp = 0x7f;
for(j = 0 ; j < 2 ; j++) //Display the first two letters
{
for(k = 0 ; k < 4 ; k++) //One letter 4BYTE
{
Send_Byte(temp); //Column selection
Send_Byte(Display_word[j][k]); //Row data
LEDARRAY_LAT = 1; //Latch data
_nop_();
LEDARRAY_LAT = 0;
_nop_();
temp = (temp>>1)|0x80;
}
}
}
for(i = 0 ; i < 1000 ; i++)
{
temp = 0x7f;
for(j = 2 ; j < 4 ; j++) //Display the first two letters
{
for(k = 0 ; k < 4 ; k++) //One letter 4BYTE
{
Send_Byte(temp); //Column selection
Send_Byte(Display_word[j][k]); //Row data
LEDARRAY_LAT = 1; //Latch data
_nop_();
LEDARRAY_LAT = 0;
_nop_();
temp = (temp>>1)|0x80;
}
}
}
}
}
//********************************************************
//Send a byte of data
//****************************************************
void Send_Byte( unsigned char dat)
{
unsigned char i;
LEDARRAY_CLK = 0;
_nop_();
LEDARRAY_LAT = 0;
_nop_();
for( i = 0 ; i < 8 ; i++ )
{
if( dat&0x01)/*This is the bitwise AND operation in C language. dat is ANDed with 0000 0001.
Then when the lowest bit of dat is not 0, it is if(1), which is true and the statement below if is executed.
Otherwise, no matter what the other bits of dat are, if the last bit is 0, it is false and the corresponding statement is not executed. */
{
LEDARRAY_DI = 1;
}
else
{
LEDARRAY_DI = 0;
}
LEDARRAY_CLK = 1; //Send data on rising edge
// _nop_();
LEDARRAY_CLK = 0;
// _nop_();
dat >>= 1;
}
}
#ifndef __MAIN_H__
#define __MAIN_H__
#include
#include
sbit LEDARRAY_LAT = P3^6;
sbit LEDARRAY_CLK = P3^5;
sbit LEDARRAY_DI = P3^4;
//函数或者变量声明
extern void Delay_ms(unsigned int n);
extern void Send_Byte( unsigned char dat);
#endif
Previous article:51 single chip microcomputer realizes the birthday song
Next article:51 MCU review: 8*8 LED dot matrix
- Popular Resources
- Popular amplifiers
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
- 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
- Creative icicle lights
- Why does the I/O port of the MSP430G2553 MCU only have pull-up/pull-down input but no pull-up/pull-down output?
- [National Technology N32WB452 Review] 2. PWM output code analysis and breathing light implementation
- Application of Nanomaterial Aluminum Oxide in Alumina Ceramics
- When the TV is in power standby mode, a large current appears. After testing the TV, I found that the electrical abnormality is original to the TV or is it leakage from the SS210 next to it?
- Today at 10:00 AM, live broadcast with prizes: Keysight Technologies 100G/400G Optical Communication Test Solutions
- Invite you to participate: The 17th Medtec China Exhibition and International Medical Device Design and Manufacturing Technology Exhibition
- What is the difference between the three pins VEE VSS VDD in the chip?
- Siemens s7-200smart modbus-rtu communication example programming detailed guide
- STM32G474 driver for HDC1080