Advertisement
Shamks412

Gas sensor code

May 22nd, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include<reg51.h>
  2. sbit gas = P3^3;
  3. sbit buzzer = P3^4;
  4. void delay(unsigned int);
  5. void main()
  6. {
  7.  while(1)
  8.  {
  9.   if(gas==1)
  10.   {
  11.     buzzer=0;
  12.     delay(100);    
  13.   }
  14.     buzzer=1;
  15.   }
  16. }
  17. void delay(unsigned int n)
  18. {
  19.  unsigned char i;
  20.  for(n;n>0;n--)
  21.  {
  22.   for(i=247;i>0;i--);
  23.   for(i=247;i>0;i--);
  24.  }
  25. }
  26.  
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement