You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MQSensorsLib/examples/MQ-2/MQ-2.ino

39 lines
719 B
Arduino

6 years ago
/*
6 years ago
MQUnifiedsensor Library - reading an MQ2
6 years ago
6 years ago
Demonstrates the use a MQ2 sensor.
6 years ago
Library originally added 01 may 2019
by Miguel A Califa, Yersson Carrillo, Ghiordy Contreras, Mario Rodriguez
Added example
modified 23 May 2019
by Miguel Califa
This example code is in the public domain.
*/
//Include the library
#include <MQUnifiedsensor.h>
6 years ago
//Definitions
#define pin A0 //Analog input 0 of your arduino
6 years ago
#define type 2 //MQ2
6 years ago
//Declare Sensor
6 years ago
MQUnifiedsensor MQ2(pin, type);
6 years ago
void setup() {
6 years ago
//Init serial port
Serial.begin(115200);
6 years ago
//init the sensor
6 years ago
MQ2.inicializar();
}
void loop() {
6 years ago
//Read the sensor and print in serial port
int lecture = MQ2.readSensor("", true);
delay(400);
}