Gas Sensor Arduino
Gas Sensor Arduino
Supplies
Arduino uno
MQ5 gas sensor
Buzzer
Breadboard
MQ5 gas sensor
Buzzer
Breadboard
Code
int gas; //random variable
void setup() {
pinMode(12,OUTPUT); //output pin for relay board, this will sent signal to the relay
pinMode(9,INPUT); //input pin coming from soil sensor
}void loop() {
gas = digitalRead(9); // reading the coming signal from the soil sensor
if(gas == HIGH) // if water level is full then cut the relay
{
digitalWrite(12,LOW); // low is to cut the relay
}
else
{
digitalWrite(12,HIGH); //high to continue proving signal and water supply
}
}
void setup() {
pinMode(12,OUTPUT); //output pin for relay board, this will sent signal to the relay
pinMode(9,INPUT); //input pin coming from soil sensor
}void loop() {
gas = digitalRead(9); // reading the coming signal from the soil sensor
if(gas == HIGH) // if water level is full then cut the relay
{
digitalWrite(12,LOW); // low is to cut the relay
}
else
{
digitalWrite(12,HIGH); //high to continue proving signal and water supply
}
}