Use STC89C52, 74hc138 to drive the columns, 74hc595 to drive the rows , 8x8 dot matrix display problem. Want to display arrows, ....... Reward points
: 30 Solved time: 2010-12-10 08:58
//= ...
The successfully debugged program is as follows:
//============================================
#include
#define uint unsigned int
#define uchar unsigned char
sbit H_shcp = P1^3; //HC595 chip
sbit H_stcp = P1^4;
sbit H_oe = P1^5;
sbit H_ds = P1^6;
sbit HC138_G = P3^1; //HC138 chip
uchar data_j[] = {0x00,0x00,0x18,0x3c,0x5a,0x18,0x18,0x00}; //arrow
uchar data_t[] = {0x00,0x66,0x99,0x81,0x81,0x42,0x24,0x18}; //heart
//------------------------------------------------------------------
void delaxms(uint xms)
{
uint i, j;
for(i = xms; i > 0; i--) for(j = 118; j > 0; j--);
}
//------------------------------------------------------------------
void sendbyte_H(uchar aa) //output using HC595
{
uchar z;
for(z = 0; z < 8; z++) { //loop 8 times to move in data
H_shcp = 0;
H_ds = aa & 0x01; //The low bit of data is sent to the HC595 data line
H_shcp = 1; //Rising edge input data
aa >>= 1; //Shift right one bit
}
H_stcp = 0;
H_stcp = 1; //Rising edge makes data output in parallel
}
//------------------------------------------------------------------
void main()
{
uint i, r;
while(1) {
for(r = 30; r > 0; r--) { //Display arrow
for(i = 0; i < 8; i++) {
HC138_G = 1; //Turn off 138, turn off display
sendbyte_H(data_j[i]); //Output arrow information
P1 = 0xd8 | i; //Wrap
HC138_G = 0; //Turn on display
delaxms(5); //Display time
} }
for(r = 10; r > 0; r--) { //Display blank
for(i = 0; i < 8; i++) {
HC138_G = 1; //Turn off 138, turn off display
sendbyte_H(0); //Output 0
P1 = 0xd8 | i; //Wrap
HC138_G = 0; //Turn on display
delaxms(5); //Display time
} }
for(r = 30; r > 0; r--) { //Display heart
for(i = 0; i < 8; i++) {
HC138_G = 1; //Turn off 138, turn off display
sendbyte_H(data_t[i]); //Output arrow information
P1 = 0xd8 | i; //Wrap
HC138_G = 0; //Turn on display
delaxms(5); //Display time
} }
for(r = 10; r > 0; r--) { //Display blank
for(i = 0; i < 8; i++) {
HC138_G = 1; //Turn off 138, turn off display
sendbyte_H(0); //Output 0
P1 = 0xd8 | i; //line break
HC138_G = 0; //turn on display
delaxms(5); //display time
} } }
}
Previous article:Use 51 single chip microcomputer as signal generator to output four frequency square waves at the same time
Next article:Usage of 51 MCU table lookup instructions
Recommended ReadingLatest update time:2024-11-16 14:28
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Teach you to learn 51 single chip microcomputer-C language version (Second Edition) (Song Xuefeng)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
- STC MCU Principles and Applications: Analysis and Design from Devices, Assembly, C to Operating Systems: A Three-Dimensional Tutorial (He Bin)
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
- GCC GD32E230 toolchain startup and linking files
- Semiconductor Recruitment-Shanghai, Shenzhen, Hangzhou
- Four major reasons for the heating of power modules
- LCR parallel resonance
- How to implement the 0-10V circuit of the inverter and motor speed control interface?
- BLE over-the-air upgrade
- Module Power Structure Design Guide
- MSP430G2755 Main Bootloader UART Porting Guide
- Zibee transparent transmission program development
- World clock controlled by NXP LPC845