Compilation error: expected constructor, destructor, or type conversion before '(' token

why i kept wrong putting my code for air pollution detection anything false? this is my code


#include "LCD.h"
#include "LiquidCrystal_I2C.h" 
LiquidCrystal_I2C::LiquidCrystal_I2C(0x27,2,1,0,4,5,6,7); 
#include "MQ135.h"
#define ANALOGPIN A2    //  Define Analog PIN on Arduino Board
#define RZERO 206.85    //  Define RZERO Calibration Value
MQ135 gasSensor = MQ135(ANALOGPIN);

int buz = 8;  //buzzer connected to pin 8
int led = 9;  //led connected to pin 9

const int aqsensor = A0;  //output of mq135 connected to A0 pin of Arduino
int threshold = 250;      //Threshold level for Air Quality

void setup() {

  pinMode (buz,OUTPUT);     // buzzer is connected as Output from Arduino
  pinMode (led,OUTPUT);     // led is connected as output from Arduino
  pinMode (aqsensor,INPUT); // MQ135 is connected as INPUT to arduino

  Serial.begin (9600);      //begin serial communication with baud rate of 9600

  lcd.clear();              // clear lcd
  lcd.begin (16,2);         // consider 16,2 lcd
}

void loop() {

  int ppm = analogRead(aqsensor); //read MQ135 analog outputs at A0 and store it in ppm

  Serial.print("Air Quality: ");  //print message in serail monitor
  Serial.println(ppm);            //print value of ppm in serial monitor

  lcd.setCursor(0,0);             // set cursor of lcd to 1st row and 1st column
  lcd.print("Air Qualit: ");      // print message on lcd
  lcd.print(ppm);                 // print value of MQ135

  if (ppm > threshold)            // check is ppm is greater than threshold or not
    {
      lcd.setCursor(1,1);         //jump here if ppm is greater than threshold
      lcd.print("AQ Level HIGH");
      Serial.println("AQ Level HIGH");     
      tone(led,1000,200);         //blink led with turn on time 1000mS, turn off time 200mS
      digitalWrite(buz,HIGH);     //Turn ON Buzzer
    }
  else
    {
      digitalWrite(led,LOW);   //jump here if ppm is not greater than threshold and turn off LED
      digitalWrite(buz,LOW);   //Turn off Buzzer
      lcd.setCursor(1,1);
      lcd.print ("AQ Level Good");
      Serial.println("AQ Level Good");
    }  
  delay (500);
}

Welcome to the forum

As your topic has nothing to do with the operation of the IDE itself it has been moved to the Programming category of the forum

Please post the full erro message (in code tags) copied from the IDE using the button provided for the purpose

First coment this ine : //#include "LCD.h"
then chage this line : LiquidCrystal_I2C::LiquidCrystal_I2C(0x27,2,1,0,4,5,6,7);
with this line : LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C

1 Like

Thank you very much bro you helped me so much, bc i'm still a beginner and almost give up because this week i have to finish it immediately, once again thank you :slightly_smiling_face:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.