// This code from https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a //Modified by Salama for Fab Academy 2018, Input Devices week. Changed pins and removed the code for buzzer #include int redLed = 2; int greenLed = 3; int smokeA0 = 7; // Your threshold value int sensorThres = 400; SoftwareSerial myserial(1,0); void setup() { pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(smokeA0, INPUT); myserial.begin(9600); } void loop() { int analogSensor = analogRead(smokeA0); myserial.print("Pin A0: "); myserial.println(analogSensor); // Checks if it has reached the threshold value if (analogSensor > sensorThres) { digitalWrite(redLed, HIGH); digitalWrite(greenLed, LOW); } else { digitalWrite(redLed, LOW); digitalWrite(greenLed, HIGH); } delay(100); }