/ ************************************************* ******************* Note: 1, when the measured concentration is greater than the set density, single-chip IO port output low ************************************************** ******************* / # Include // library files #define uchar unsigned char // macro definition unsigned char #define uint unsigned int // macro definition unsigned int / ************************************************* ******************* I / O definitions ************************************************** ******************* / sbit LED = P1 ^ 0; // define microcontroller P1 port of the first one (ie P1.0) to indicate the end sbit DOUT = P2 ^ 0; // define 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 port 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 the concentration higher than the set value, the implementation of the Con { LED = 0; // P1.0 port lights lit } } } } / ************************************************* ******************* End ************************************************** ****************** /
Ваш отзыв может быть первым.