#include "MQ135.h" //Main library that contains functions to get the ppm values #include #include //Header file for LCD LiquidCrystal_I2C lcd(0x27,16,2);//set the LCD address to x27 for a 16 chars and 2 line display #define led 9 //led on pin 9 const int gas_pin = A0; //analog feed from MQ135 MQ135 gasSensor = MQ135(gas_pin); //Define the gas pin in the function mq135 gas sensor as per the mq135 library void setup(){ lcd.init(); // initialize the lcd lcd.begin(16,2); // consider 16 chars + 2 lines lcd lcd.backlight(); // illuminate to produce visible reading lcd.clear(); // clear lcd lcd.setCursor(4,0); //set cursor of lcd to 1st row and 5th column lcd.print("Group L"); // print as a sentence on lcd pinMode(gas_pin,INPUT); //MQ135 analog feed set for input pinMode(led,OUTPUT); //led set for output Serial.begin(9600); //serial comms for debugging } void loop(){ float ppm = gasSensor.getPPM(); //function to get ppm value based on the MQ135.h library Serial.println(ppm); // print ppm on serial monitor delay(1000); lcd.clear(); // clear lcd lcd.setCursor(0,0); // set cursor of lcd to 1st row and 1st column lcd.print("Air Quality: "); // print as a sentence on lcd lcd.print(ppm); // print value of MQ135 if(ppm>999){ //if co2 ppm > 1000 digitalWrite(led,HIGH); //turn on led lcd.setCursor(2,1); // set cursor of lcd to 2nd row and 3rd column lcd.print("AQ Level BAD"); //print as a sentence on lcd } else{ digitalWrite(led,LOW); //turn off led lcd.setCursor(1,1); // set cursor of lcd to 2nd row and 2nd column lcd.print ("AQ Level Good"); // print as a sentence on lcd } }