0% found this document useful (0 votes)
16 views

mq4 Sensor

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

mq4 Sensor

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <LiquidCrystal_I2C.

h>
#include <Wire.h>

const int FirstSensorAO_Pin=1; // Connect the AO of MQ-4 sensor with analog


channel 0 pin (A0) of Arduino
const int FirstSensorDO_Pin=9; // Connect the DO of MQ-4 sensor with digital pin
8 (D8) of Arduino
int FirstSensorAO_Out; // Create a variable to store the analog output of the MQ-
4 sensor

const int SecondSensorAO_Pin=2; // Connect the AO of MQ-4 sensor with analog


channel 0 pin (A0) of Arduino
const int SecondSensorDO_Pin=8; // Connect the DO of MQ-4 sensor with digital pin
8 (D8) of Arduino
int SecondSensorAO_Out; // Create a variable to store the analog output of the
MQ-4 senso

LiquidCrystal_I2C lcd(0x27,16,2);

void setup() {
Serial.begin(115200);

lcd.init();
lcd.backlight();

pinMode(FirstSensorDO_Pin, INPUT); // Set the D8 pin as a digital input pin


pinMode(SecondSensorDO_Pin, INPUT);

void loop() {

lcd.setCursor(0, 0);
// Read the analog output measurement sample from the MQ4 sensor's AO pin
lcd.print ("CH4 input: "); // Print out the text "Methane Concentration: "
lcd.print (FirstSensorAO_Out); // u out the methane value - the analog output -
beteewn 0 and 1023

lcd.setCursor(0,1);
// Read the analog output measurement sample from the MQ4 sensor's AO pin
lcd.print ("CH4 output: "); // Print out the text "Methane Concentration: "
lcd.print (SecondSensorAO_Out); // u out the methane value - the analog output -
beteewn 0 and 1023

FirstSensorAO_Out= analogRead(FirstSensorAO_Pin); // Read the analog output


measurement sample from the MQ4 sensor's AO pin
Serial.print ("CH4 input: "); // Print out the text "Methane Concentration: "
Serial.print (FirstSensorAO_Out); // u out the methane value - the analog output
- beteewn 0 and 1023
Serial.print (" , ");

SecondSensorAO_Out= analogRead(SecondSensorAO_Pin); // Read the analog output


measurement sample from the MQ4 sensor's AO pin
Serial.print ("CH4 output: "); // Print out the text "Methane Concentration: "
Serial.println (SecondSensorAO_Out); // u out the methane value - the analog
output - beteewn 0 and 1023

delay(1000);
}

You might also like