Papermind

mq5

Mar 22nd, 2018
4,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. /*
  2. MQ-5
  3. Created by papermindvention.blogspot.com
  4. March 2018
  5. */
  6. const int buzzer = 3;
  7.  
  8. void setup() {
  9.  Serial.begin(9600);
  10.  pinMode(buzzer, OUTPUT);
  11. }
  12.  
  13. void loop() {
  14.   int mq5=analogRead(A0);
  15.   Serial.println (mq5);
  16.   if (mq5 >= 100){ tone(buzzer, 90);  delay (100);  }
  17.   if (mq5 >= 300){ tone(buzzer, 500); delay (80);   }
  18.   if (mq5 >= 500){ tone(buzzer, 2000); delay (50);   }
  19.   else{ noTone(buzzer);  }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment