Example Code for Arduino-Gas Value Reading
Last revision 2025/12/15
Learn how to read gas values using Arduino with detailed instructions on hardware setup, software installation, wiring diagrams, and sample code for serial output.
Hardware Preparation
- DFRduino UNO R3 with IO Expansion Shield and USB Cable A-B x1
- Gravity: Analog Propane Gas Sensor (MQ6) x1
- Gravity Analog Cable (Gift) x1
Software Preparation
- Arduino IDE
- Download and install the XXX Library. (About how to install the library?)
Wiring Diagram

Sample Code
///Arduino Sample Code
void setup()
{
Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(0);//Read Gas value from analog 0
Serial.println(val,DEC);//Print the value to serial port
delay(100);
}
Was this article helpful?
