Need Help PLZ. Getting error message

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeMonoOblique9pt7b.h>
#include <DHT.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define sensor A0;
#define DHTPIN 2 // Digital pin 2
#define DHTTYPE DHT11; // DHT 11

#define int gasLevel = 0; //int variable for gas level
#define String quality ="";
#define DHT dht(DHTPIN, DHTTYPE);

#define void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
display.setTextColor(WHITE);
display.setTextSize(1);
display.setFont();
display.setCursor(0, 43);
display.println("Temp :");
display.setCursor(80, 43);
display.println(t);
display.setCursor(114, 43);
display.println("C");
display.setCursor(0, 56);
display.println("RH :");
display.setCursor(80, 56);
display.println(h);
display.setCursor(114, 56);
display.println("%");
}

void air_sensor()
{
gasLevel = analogRead(sensor);

if(gasLevel<181){
quality = " GOOD!";
}
else if (gasLevel >181 && gasLevel<225){
quality = " Poor!";
}
else if (gasLevel >225 && gasLevel<300){
quality = "Very bad!";
}
else if (gasLevel >300 && gasLevel<350){
quality = "ur dead!";
}
else{
quality = " Toxic";
}

display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(1,5);
display.setFont();
display.println("Air Quality:");
display.setTextSize(1);
display.setCursor(20,23);
display.setFont(&FreeMonoOblique9pt7b);
display.println(quality);

}

void setup() {
Serial.begin(9600);
pinMode(sensor,INPUT);
dht.begin();
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
}

display.clearDisplay();
display.setTextColor(WHITE);

display.setTextSize(2);
display.setCursor(50, 0);
display.println("Air");
display.setTextSize(1);
display.setCursor(23, 20);
display.println("Qulaity monitor");
display.display();
delay(1200);
display.clearDisplay();

display.setTextSize(2);
display.setCursor(20, 20);
display.println("BY Abid");
display.display();
delay(1000);
display.clearDisplay();

void loop() {
display.clearDisplay();
air_sensor();
sendSensor();
display.display();
}

There is an error message on the line: "void setup () {". The error message says "expected constructor, destructor or type conversion before ";" token. It's on the arduino IDE, not c++.

Oops

Please remember to use code tags when posting code

More oops.

No, the C++ compiler is generating these errors.

That one's a nasty one

You should remove these #define. Not the whole line just #define:

#define Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define sensor A0;
#define int gasLevel = 0; //int variable for gas level
#define String quality ="";
#define DHT dht(DHTPIN, DHTTYPE);
#define void sendSensor()

What do I do to fix the code ? What lines need fixing

Just about everything, between

#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)

And

void air_sensor()

And then you need to figure out where the setup function ends, and the loop function starts.

But then

sensor A0;

Makes even less sense :wink:

Yes. I realized my copypasta error. :rofl:

with

any

kind of "please" "plz" and similar words in the headline
you

annoy

users "OMG just another one of those guys that is in a hurry for "write my code"

Yes I’m very much in a hurry :rofl::rofl::rofl:

bruh help us then, literally due in two days,, idk how to fix it :wink: :shushing_face: :stuck_out_tongue_winking_eye: :crazy_face:

how do we fix it ? dawg this thing is due in 2 days. I hate computer science. Help a young brotha out. H

As mentioned, remove the inappropriate #defines.
Work through it.
Report your progress, using code tags

(I'm not entirely sure I know what a "brotha" is, young or otherwise)

Nope, didn't get any of that.

ight thanks cuh, you a real one, ona dead locs. :100:

I think by "how do we fix it?" the OP means us.

You can start by changing the following lines from:

#define Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define sensor A0;
#define int gasLevel = 0; //int variable for gas level
#define String quality ="";
#define DHT dht(DHTPIN, DHTTYPE);
#define void sendSensor()

to:

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define sensor A0
int gasLevel = 0; //int variable for gas level
String quality ="";
DHT dht(DHTPIN, DHTTYPE);
void sendSensor()

thx dawg, you an og, cuhhh. :point_right: :point_left:

Still a solid "nope"

We speak English here.

1 Like