#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-23 08:06
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- 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)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Using WS2812 on ESP32-S2-Saola-1
- Can the LF356 op amp amplify current without any peripheral devices?
- Data Acquisition (DAQ) Basics (Part 2)
- How to connect the freewheeling diode
- Design Techniques for Planar UWB Antennas for Communications
- Online programming tool SplootCode Editor
- Detailed explanation of ADC of MSP430 microcontroller
- Component packaging,
- Question about the placement of pull-up resistors
- 5 Key Considerations for IoT Devices