#include
#include
#define uchar unsigned char //macro definition of unsigned character type
#define uint unsigned int //macro definition of unsigned integer
sbit ST=P3^0; //A/D start conversion signal
sbit OE=P3^1; //Data output enable signal
sbit EOC=P3^2; //A/D conversion end signal
sbit CLK=P3^3; //clock pulse
uint i,j,AD0809; //define data type
//Delay sub-function
void delay()
{
i = 1000;
while(i--);
}
/****************************************************** ************************
CLK oscillation signal
*************************************************** ************************/
void timer0() interrupt 1 //Timer 0 working mode 1
{
TH0=(65536-2)/256; //Reload count initial value
TL0=(65536-2)%256; //Reload count initial value
CLK=!CLK; //Invert
}
/****************************************************** ************************
Main function
*************************************************** ************************/
void main()
{
TMOD=0X01; //Timer interrupt 0
CLK=0; //The initial value of the pulse signal is 0
TH0=(65536-2)/256; //initial value of the high 8 bits of the timing time
TL0=(65536-2)%256; //initial value of the lower eight bits of the timing time
EA=1; //Open CPU interrupt
ET0=1; //Open T/C0 interrupt
TR0=1;
while(1) // infinite loop
{
ST=0; // Make the acquisition signal low
ST=1; //Start data conversion
ST=0; //Stop data conversion
while(!EOC); //Wait for data conversion to complete
OE=1; //Allow data output signal
AD0809=P1; //Read data
OE=0; //Turn off data output enable signal
if(AD0809>=251) //The voltage displayed cannot exceed 5V
{
AD0809=250;
P2 = 0xE0; //Alarm flashing LED light
delay();
P2 =~0xE0;
delay();
P0 = ~0x06; //Digital tube alarm display 1
delay();
P0 = ~0x00;
delay();
}
}
}
Previous article:Digital-to-Analog Converter ADC08009 Application
Next article:Controlling LED Lights with a Microcontroller (Project)
Recommended ReadingLatest update time:2024-11-15 02:23
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- The difference between dsp2812 and dsp28335
- Are the salaries for test development positions higher than those for development?
- Could you please tell me how to generate a single-sided coordinate file in ALTIUM?
- Does anyone want to buy the new DY-FFTB6638 Deyan Electronics MSP430 development kit?
- Boost circuit
- Domestic 32-bit MCU compatibility test non-authoritative report - AT32F403 compatibility test
- A young man uses stones to extract silicon to make chips, claiming to "solve" the chip crisis in 99 seconds
- Learn about vector network analysis Smith chart and filter bandwidth measurement!
- Answer a question to win a Kindle, "New Concept Analog Circuit": Browse ADI IoT reference designs together
- TI CCS & controlSUITE Troubleshooting Log