Code:
#include
#define uint unsigned int
#define uchar unsigned char
//sbit A=P2^0;
//sbit B=P2^1;
//sbit C=P2^2;
void delay(uchar);
uchar code table[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};
//Common cathode digital tube font code table
void main()
{
//uchar i;
while(1)
{
P2=(0X00)&(0X07); //位选
P0=table[2]; //段选
delay(1);
P2=(0X01)&(0X07);
P0=table[0];
delay(1);
P2=(0X02)&(0X07);
P0=table[0];
delay(1);
P2=(0X03)&(0X07);
P0=table[8];
delay(1);
P2=(0X04)&(0X07);
P0=table[0];
delay(1);
P2=(0X05)&(0X07);
P0=table[8];
delay(1);
P2=(0X06)&(0X07);
P0=table[0];
delay(1);
P2=(0X07)&(0X07);
P0=table[8];
delay(1);
}
}
void delay(uchar y) //延时程序
{
uchar i;
uint j;
for(i=0;i
for(j=0;j<100;j++);
}
}
In this example, the result is 20080808. The specific level can be selected according to the character code table.
Previous article:Control the on and off of the water lamp by timing
Next article:Combined with the single-chip learning board to learn C language and make water lamps-intrins.h header file
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
- 104 capacitors are the most widely used, whether it is power supply filtering or ADC filtering, can any forum friends tell me? Why not 102...
- [Silicon Labs BG22-EK4108A Bluetooth Development Evaluation] 3. Bluetooth protocol test APP lighting and button detection
- [Goodbye 2021, hello 2022] Stop looking at refrigeration units and start clean air conditioning
- What is the difference between quick format and normal format?
- Wake-up function of pedometer bracelet based on F103 and X-NUCLEO-IKS01A3
- Recruiting MBSE part-time training instructors
- [Qinheng Trial] CH559 Development Environment Construction
- Detailed explanation of analog ground and digital ground
- Recently, when I logged into MYTI, I needed to verify my email address, but I didn’t receive any email from Ti in my mailbox. Has anyone encountered this before?
- Principles of MCU Hardware System Design