Smoke sensor based on AT89C51 microcontroller

Publisher:心动旋律Latest update time:2024-08-14 Source: cnblogsKeywords:AT89C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#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();

}

}

}


Keywords:AT89C51 Reference address:Smoke sensor based on AT89C51 microcontroller

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

Temperature measurement method using AT89C51 and DS18B20
  Temperature measurement and control are widely used in the use of lasers, fiber gratings, and other industrial and agricultural production and scientific research. The traditional method of temperature detection is to use analog temperature sensors such as thermocouples, thermal resistors, and semiconductor PN junct
[Microcontroller]
Temperature measurement method using AT89C51 and DS18B20
What is the difference between AT89C51 and AT89S51 microcontrollers?
AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller. It contains 8k Bytes ISP (In-system programmable) Flash read-only program memory that can be repeatedly erased and written 1000 times. The device adopts ATMEL's high-density, non-easy-to-use Made with lossy memory technology, it is compatible with th
[Microcontroller]
AT89C51 MCU Performance Introduction
AT89C51 is a low-voltage, high-performance CMOS 8-bit microprocessor with 4K bytes of flash programmable and erasable read-only memory (FPEROM), commonly known as a single-chip microcomputer. The device is manufactured using ATMEL's high-density non-volatile memory manufacturing technology and is compatible with the i
[Microcontroller]
MCU PWM wave (AT89C51, ADC0808)
1. Introduction This circuit is composed of AT89C51 minimum system and ADC0808. 2. Operation Effect 3. Code /*Want more projects private wo!!!*/ #include reg52.h #define uint unsigned int #define uchar unsigned char sbit CLK = P2^4; sbit ST = P2^5; sbit EOC = P2^6; sbit OE = P2^7; sbit PWM = P3^0; void Delay
[Microcontroller]
MCU PWM wave (AT89C51, ADC0808)
Microcontroller AT89C51--3. Light up the LED light
1. What is LED light? LED: Semiconductor light-emitting diode. Directly convert electrical energy into light energy 2. LED operating parameters The working voltage drop of ordinary light-emitting diodes is: 1.6-2.1 Working current: 1-20mA The current is about 3mA, I=(5-2)/1K 3. Schematic analysis J9 means ju
[Microcontroller]
Microcontroller AT89C51--3. Light up the LED light
Design Principle and Application of Burglar Alarm
Traditional wired burglar alarms only sound an alarm locally when a theft is detected. There is no controller inside, so it is easy to be damaged and fail. It is also inconvenient to install and expand. The wireless burglar alarm designed in this paper is controlled by a single-chip microcomputer. It is powerful and e
[Microcontroller]
Design Principle and Application of Burglar Alarm
Design of control keyboard based on AT89C51
Introduction  In some automated measurement or intelligent equipment, the microcomputer acts as the control center to control and manage multiple functional units to realize the system functions of the instrument and equipment. The keyboard is the basic device for human-computer communication, and the operator uses
[Microcontroller]
Design of control keyboard based on AT89C51
Design of diesel engine test system based on single chip AT89C51 and CAN controller
1 Introduction Many diesel engine test platforms currently in use use instrument readings to analyze and judge the working status of a diesel engine during testing. This is not only low in efficiency and poor in accuracy, but also has limited comprehensive analysis and judgment capabilities. In order to have a more co
[Microcontroller]
Design of diesel engine test system based on single chip AT89C51 and CAN controller
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号