The if message (gas detected) doesn't appear when I test the gas sensor

void setup() {


void loop() {
  int data=analogRead(A0);
  int mapper= map(data,0,1023,0,255);
      Serial.println("Gas detected");     // debug value

    Serial.println("No gas detected");

And I'm sure that the circuit is great and nth wront with it

Have you tried values lower than 220?

Have you tried replacing the sensor with a pot to simulate the sensor signal, for troubleshooting?

Insert serial prints to confirm the values of your data and mapper variables.

No, I didn't, what do u suggest, what number would make it work. The thing is I'm a beginner and I'm still learning and I don't have much experience in this.

Can you fix it?

add a simple Serial.println(analogRead(A0); to see what happens.


int mapper = data / 4;

I did, nth changed

But something got printed, surely?

Still not working

Don't ever use that phrase again.

What did you do and what not happens ?

Yes, it prints No gas detected but when I press the logic toggle nth change and the second message doesn't appear

No, what VALUE does it print?

show your wiring diagram and a photo.

It doesn't print any value

Well make it print the value of "data" as already suggested.

Have you built the physical circuit?

This when I press on the logic toggle

I build nth but this, and under the instruction of a guy on the youtube