Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- MQ-5
- Created by papermindvention.blogspot.com
- March 2018
- */
- const int buzzer = 3;
- void setup() {
- Serial.begin(9600);
- pinMode(buzzer, OUTPUT);
- }
- void loop() {
- int mq5=analogRead(A0);
- Serial.println (mq5);
- if (mq5 >= 100){ tone(buzzer, 90); delay (100); }
- if (mq5 >= 300){ tone(buzzer, 500); delay (80); }
- if (mq5 >= 500){ tone(buzzer, 2000); delay (50); }
- else{ noTone(buzzer); }
- }
Advertisement
Add Comment
Please, Sign In to add comment