Hey,
In today's blog we are going to make gas leak alert system using Arduino Uno.
WHAT YOU NEED :
Arduino Uno
Gas sensor MQ5
LED bulb
5mm green LED
Buzzer
5v 2.5 a power supply
Breadboard
Jumper wires
CODE :
int redLed = 12; int greenLed = 11; int buzzer = 10; int smokeA0 = A5; // Your threshold value int sensorThres = 120; void setup() { pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(buzzer, OUTPUT); pinMode(smokeA0, INPUT); Serial.begin(9600); }void loop() { int analogSensor = analogRead(smokeA0); Serial.print("Pin A0: "); Serial.println(analogSensor); // Checks if it has reached the threshold value if (analogSensor > sensorThres) { digitalWrite(redLed, HIGH); digitalWrite(greenLed, LOW); digitalWrite(buzzer, HIGH); } else { digitalWrite(redLed, LOW); digitalWrite(greenLed, HIGH); digitalWrite(buzzer, LOW); } delay(100); }
Making electronics project is too pretty simple with Us.
Join and Make with Us.
Comments