void setup() {
Serial.begin(9600);
}
void loop() {
int data=analogRead(A0);
int mapper= map(data,0,1023,0,255);
if(mapper>220)
{
Serial.println("Gas detected"); // debug value
}
else
{
Serial.println("No gas detected");
}
}
And I'm sure that the circuit is great and nth wront with it
shesherees:
if(mapper>220)
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.
Hello
add a simple Serial.println(analogRead(A0); to see what happens.
But something got printed, surely?
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