#include
#include
//#include
sbit ST=P3^2;
sbit EOC=P3^1;
sbit OE=P3^0;
sbit ADDA=P3 ^4;
sbit ADDB=P3^5;
sbit ADDC=P3^6;
unsigned char a,b,c;
unsigned char code dispbitcode[]={0x00,0x08,0x04,0x02,0x01};//shared negative bit code
unsigned char code dispcode[]={ 0X3F,/*0*/
0X06,/*1*/
0X5B,/*2*/
0X4F,/*3*/
0X66,/*4*/
0X6D,/*5*/
0X7D,/*6*/
0X07,/*7*/
0X7F,/*8*/
0X6F,/*9*/
};//Common cathode segment code
/*************Delay subroutine*** ****************************/
void delay(unsigned int x) //minimum 1 millisecond
{
unsigned char j;
while(x- -)
{
for(j=0;j<125;j++)
{;}
}
}
/***************Display subroutine*********** ***********/
void display(unsigned char bai,unsigned char shi,unsigned char ge)
{
//P3=dispbitcode[5];
//P2=dispcode[11];
P2=dispbitcode[ 1];
P0=dispcode[bai]; //Display hundreds digit
delay(5);
//P3=dispbitcode[5];
//P2=dispcode[11];
P2=dispbitcode[2];
P0=dispcode[shi]; //display tens digit
delay(5);
//P3=dispbitcode[5];
//P2=dispcode[11];
P2=dispbitcode[3];
P0=dispcode[ge]; / /Display the unit digit
delay(5);
}
void main(void)
{
unsigned char c;
ADDA=0;
ADDB=0;
ADDC=0; //Select channel 0
while(1)
{
ST=0;
ST=1; //Start AD conversion_nop_
(); //The program performs no operation once, that is, delay;
ST=0;
delay(1); // Delay and wait for the conversion to end
OE =1; // Output the converted data
c=P1; // Write down the obtained data
OE = 0;
a=c/100; //Send to display
b=c%100/10;
c=c%100%10;
display(a,b,c);
}
}
Previous article:DS18B20 single bus temperature control
Next article:8255 Expansion I/O
Recommended ReadingLatest update time:2024-11-17 00:21
- Popular Resources
- Popular amplifiers
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- Signal and System Experiment Tutorial (Edited by Jin Bo)
- Effective Unit Testing (Lasse Koskela)
- Operational Amplifier Practical Reference Handbook (Edited by Liu Changsheng, Zhao Mingying, Liu Xu, etc.)
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
- The domestic Gaoyun FPGA GWIN-4B development board cannot use the MSPI pin. Please help
- Shanghai is a cold and indifferent society now,,,,,I don't want to say more
- sp485 communication reception is 0x00
- Xunwei 4412 development board Qt network programming-UDP implementation of server and client
- AD Wiring "hitting a wall"! ? ?
- How to solve the three major problems of wireless video surveillance?
- LiteOS Kernel Tutorial 04-Semaphore
- Purgatory Legend-ROM War
- Share: Type 81 (102D) electronic tube transceiver used by the Chinese People's Volunteer Army in the War to Resist U.S. Aggression and Aid Korea
- The distance between the pins is 0.8mm. It worked fine for a month, but was later found to be short-circuited. How can I find the current path between them?