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-23 08:06

Application of AT89C51 single chip microcomputer in the design of LED display screen control circuit
LED display, also known as electronic display, is composed of LED dot matrix, which displays text, pictures, animations, and videos by turning on and off red or green lamp beads. The content can be changed at any time. It is usually composed of display module, control system and power supply system. The display module
[Power Management]
Application of AT89C51 single chip microcomputer in the design of LED display screen control circuit
Software Design of Temperature Intelligent Control System Based on AT89C51
The development of ultra-large-scale integrated circuit technology has promoted the birth of single-chip microcomputers, which have the characteristics of strong functions, high cost performance, high reliability, low power consumption and small size. The emergence of single-chip microcomputer technology has not only i
[Microcontroller]
Software Design of Temperature Intelligent Control System Based on AT89C51
Design of three-phase inverter power supply based on SA8282
  1. Introduction   The inverter is the core part of the AC uninterruptible power supply (UPS) and AC variable frequency speed regulation system. It can independently form a system to become a variable frequency power supply device. Inverter power supplies are widely used in industry, but most inverter power supply
[Microcontroller]
Design of three-phase inverter power supply based on SA8282
A high-precision countdown system based on AT89C51 control
1 Introduction The task of the countdown system is to count down to a set date and display the time from the current date to the set date on the display screen to enhance people's attention and sense of urgency. Development practice shows that the high-precision countdown system with clock chip DS12C887 as the cloc
[Industrial Control]
A high-precision countdown system based on AT89C51 control
Design of embedded frequency meter
  1   Introduction     The design of this frequency meter takes the AT89C51 microcontroller as the core and uses its internal timer/counter to complete the measurement of the period/frequency of the signal to be measured. The microcontroller AT89C51 has two 16-bit timers/counters inside. The work of the timers/counte
[Test Measurement]
Application of AT89C51 single chip microcomputer in the design of LED display screen control circuit
LED display, also known as electronic display, is composed of LED dot matrix, which displays text, pictures, animations, and videos by turning on and off red or green lamp beads. The content can be changed at any time. It is usually composed of display module, control system and power supply system. The display module
[Power Management]
Application of AT89C51 single chip microcomputer in the design of LED display screen control circuit
Design of Automatic Temperature Measurement and Alarm System Based on AT89C51
At present, whether in industrial production or scientific research experiments, the equipment for automatic control through temperature measurement is becoming more and more popular, and there are more and more application occasions. The problem that follows is how to measure the accurate temperature to ensure that
[Microcontroller]
Design of Automatic Temperature Measurement and Alarm System Based on AT89C51
Application of AT89C5131 in Interface Design
  AT89C5131 is a MCU based on 52 core. In terms of memory, it integrates 32KB Flash memory for code storage and 1KB EEPROM memory for user data storage. Users can use the on-chip Bootloader or Flash API to perform ISP or IAP programming on the Flash memory and EEPROM memory through the USB interface or other interface
[Microcontroller]
Application of AT89C5131 in Interface Design
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号