Testing procedures]
1, when the measured concentration is greater than the set concentration, single-chip IO port output low
/ ************************************************* *******************
Function: This version supporting test procedures
Using a Chip: AT89S52
Crystal: 11.0592MHZ
Baud Rate: 9600
Compiler Environment: Keil
[Statement] This procedure is used only for study and reference, please indicate the copyright and author information!
************************************************** ******************* /
/ ************************************************* *******************
Note: 1, when the measured concentration is greater than the set concentration, single-chip IO port output low
************************************************** ******************* /
#include // library
#define uchar unsigned char // unsigned char macro definition
#define uint unsigned int // macros unsigned integer
/ ************************************************* *******************
I / O definitions
************************************************** ******************* /
sbit LED = P1 ^ 0; // definition of the microcontroller P1 port of the first one (ie P1.0) to indicate the end
sbit DOUT = P2 ^ 0; // definition of the microcontroller P2 port first one (ie P2.0) as an input sensor
/ ************************************************* *******************
Delay function
************************************************** ******************* /
void delay () // delay procedure
{
uchar m, n, s;
for (m = 20; m> 0; m--)
for (n = 20; n> 0; n--)
for (s = 248; s> 0; s--);
}
/ ************************************************* *******************
The main function
************************************************** ******************* /
void main ()
{
while (1) // infinite loop
{
LED = 1; // Off P1.0 mouth lights
if (DOUT == 0) // When the concentration is higher than the set value, the implementation of the Con
{
delay (); // delay interference
When if (DOUT == 0) // determine concentrations higher than the set value, the implementation of the Con
{
LED = 0; // P1.0 port lights lit
}
}
}
}
/ ************************************************* *******************
End
Gas sensors MQ-2
- รหัสสินค้า: Gas sensors MQ-2
- สินค้าในสต็อก: 1
-
160.00 บาท