Last active
March 24, 2020 23:04
-
-
Save Sidchou/dd3c076a534bbf97afabb30a3badec4c to your computer and use it in GitHub Desktop.
MQ2 sensor test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
simple code to test MQ-2 Gas Sensor Detection Module | |
*/ | |
const int digitalPin = 3; | |
const int analogPin = A0; | |
//declare input pins | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(digitalPin, INPUT); | |
pinMode(analogPin, INPUT); | |
//declare pinmode | |
Serial.begin(9600); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
int analogReading = analogRead(analogPin); | |
bool digitalReading = digitalRead(digitalPin); | |
Serial.print(analogReading); | |
Serial.print("\t"); | |
Serial.println(digitalReading); | |
//print sensor reading on Serial | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment