Expected constructor, destructor, or type conversion before '(' token | i need some help

#include <MQ2.h>

//change this with the pin that you use
int pin = A0;
float lpg, co, smoke;
pinMode(6, OUTPUT);
MQ2 mq2(pin);

void setup(){
  Serial.begin(9600);
  
  // calibrate the device
  mq2.begin();
}

void loop(){
  
  /*
   * read the values from the sensor, it returns
   * an array which contains 3 values.
   * 0 : LPG in ppm
   * 1 : CO in ppm
   * 2 : SMOKE in ppm
   */
  float* values= mq2.read(true); //set it false if you don't want to print the values to the Serial
  
  // lpg = values[0];
  lpg = mq2.readLPG();
  // co = values[1];
  co = mq2.readCO();
  // smoke = values[2];
  smoke = mq2.readSmoke();
  
  delay(1000);
}

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Placa:"Arduino Uno"

sketch_sep29a:6:8: error: expected constructor, destructor, or type conversion before '(' token

pinMode(6, OUTPUT);

    ^

exit status 1

expected constructor, destructor, or type conversion before '(' token

1 Like

that goes into setup().

1 Like

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