Experiment name: LED dot matrix experiment (display image)
Wiring instructions:
Experimental phenomenon: After downloading the program, the 8*8 LED dot matrix displays a heart shape.
Note: The J24 yellow jumper cap next to the LED dot matrix is shorted to the GND end
*** *************************************************** **********************************/
#include "reg51.h"
typedef unsigned int u16; //Redefine the system default data type
typedef unsigned char u8;
//Define 74HC595 control pin
sbit SRCLK=P3^6; //Shift register clock input
sbit RCLK=P3^5; //Storage register clock input
sbit SER=P3^4; //Serial data input
#define LEDDZ_COL_PORT P0 //Point array control port
u8 gled_row[8]={0x38,0x7C,0x7E,0x3F,0x3F,0x7E,0x7C,0x38};//LED dot matrix display image row data
u8 gled_col[8]={0x7f,0xbf,0xdf,0xef,0xf7 ,0xfb,0xfd,0xfe};//Column data of LED dot matrix display image
/****************************************************** ****************************
* Function name: delay_10us
* Function function: Delay function, when ten_us=1, the delay is approximately 10us
* Input: ten_us
* Output: None
**************************************** ***************************************/
void delay_10us(u16 ten_us)
{
while(ten_us --);
}
/****************************************************** ******************************
* Function name: hc595_write_data(u8 dat)
* Function function: Write one byte to 74HC595 data
* input: dat:data
* output: none
****************************************** *****************************************/
void hc595_write_data(u8 dat)
{
u8 i=0;
for(i=0;i<8;i++)//Loop 8 times to write a byte into the register
{ SER=dat>>7;//Transmit the high-order dat
of a byte first
<<=1;//Move the low bit to the high bit
SRCLK=0;
delay_10us(1);
SRCLK=1;
delay_10us(1);//The rising edge of the shift register clock sends the port data into the register
}
RCLK=0;
delay_10us(1);
RCLK=1;//The rising edge of the storage register clock will output the data previously written to the register
}
/****************************************************** ******************************
* Function name: main
* Function function: main function
* Input: None
* Output: None
* *************************************************** ****************************/
void main()
{
u8 i=0;
while(1)
{
for(i=0;i<8;i++)//Loop 8 times to scan 8 rows and columns
{
LEDDZ_COL_PORT=gled_col[i];//Transmit column selection data
hc595_write_data(gled_row[i]);/ /Transmit row selection data
delay_10us(100);//Delay for a period of time, waiting for the display to stabilize
hc595_write_data(0x00);//Eliminate shadow
}
}
}
Previous article:51 Microcontroller Learning: DC Motor Experiment
Next article:51 microcontroller learning: LED dot matrix experiment (display numbers)
Recommended ReadingLatest update time:2024-11-16 13:47
- Popular Resources
- Popular amplifiers
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
- Request X-CUBE-MEMS1 firmware package
- TI CCS compiler download update
- Simple and efficient zero-point acquisition circuit
- BMS solutions for electric bicycles and electric motorcycles under the new national standard for electric vehicles
- How to choose the type and model of diode in circuit design
- 【DWIN Serial Port Screen】Practical Application
- [National Technology N32G457 Review] RT-Thread drives SSD1306
- IIC communication problem between MSP430 and SHT11
- MSP430.dll initialization error occurs in the MSP430 download program
- A Problem with TTL Inverter Circuit