From c10e85748a055c41b39f52cba086aa33040e9e46 Mon Sep 17 00:00:00 2001 From: Konstantinos Kamaropoulos Date: Thu, 9 Jan 2020 22:24:58 +0200 Subject: [PATCH] feat: Add source code for reading gas sensor values --- Aiolos_Drone.ino | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Aiolos_Drone.ino diff --git a/Aiolos_Drone.ino b/Aiolos_Drone.ino new file mode 100644 index 0000000..7d68379 --- /dev/null +++ b/Aiolos_Drone.ino @@ -0,0 +1,55 @@ +int MQ2 = A0; +int MQ4 = A1; +int MQ5 = A2; +int MQ6 = A3; +int MQ7 = A4; +int MQ8 = A5; +int MQ9 = A6; +int MQ135 = A7; + +void setup() { + + pinMode(MQ2, INPUT); + pinMode(MQ4, INPUT); + pinMode(MQ5, INPUT); + pinMode(MQ6, INPUT); + pinMode(MQ7, INPUT); + pinMode(MQ8, INPUT); + pinMode(MQ9, INPUT); + pinMode(MQ135, INPUT); + Serial.begin(9600); +} + +void loop() { + float GAS_MQ2 = analogRead(MQ2); + float GAS_MQ4 = analogRead(MQ4); + float GAS_MQ5 = analogRead(MQ5); + float GAS_MQ6 = analogRead(MQ6); + float GAS_MQ7 = analogRead(MQ7); + float GAS_MQ8 = analogRead(MQ8); + float GAS_MQ9 = analogRead(MQ9); + float GAS_MQ135 = analogRead(MQ135); + + if (Serial.available()>0) { + int x=Serial.read(); + if (x=='1') { + Serial.print("MQ2: "); + Serial.println(GAS_MQ2); + Serial.print("MQ4: "); + Serial.println(GAS_MQ4); + Serial.print("MQ5: "); + Serial.println(GAS_MQ5); + Serial.print("MQ6: "); + Serial.println(GAS_MQ6); + Serial.print("MQ7: "); + Serial.println(GAS_MQ7); + Serial.print("MQ8: "); + Serial.println(GAS_MQ8); + Serial.print("MQ9: "); + Serial.println(GAS_MQ9); + Serial.print("MQ135: "); + Serial.println(GAS_MQ135); + Serial.println("\n"); + } + } +}