can anyone helpme with this, I'm trying to turn a led in a loop if the condition is encoutered but can't get it to turn on
I knoe the condition works since the script doess send me my pushover message and the result is post on MQTT
than ks
oid loop()
{
int state=digitalRead(soundSensor);
if(state==1) //when detect some sound
{
delay(100);
digitalWrite(LED, HIGH);
delay(100);
Serial.println("ON");
// publie resultat sur MQTT
delay(2000);
client.publish("/ESP_test/test","Sond ON");
delay(2000);
// envoi message pushover
Pushover po = Pushove("XXX"); //premier parametre cle de api de l'application cree, 2 ieme cle usager
po.setDevice("iphoneb");
po.setTitle("Sons");
po.setMessage("Patch a parlé");
po.setSound("bike");
Serial.println(po.send()); //should return 1 on success
}
else
{
digitalWrite(LED, LOW);
Serial.println("Off");
}
}
Did you set pinMode(LED, OUTPUT) for the pin in setup? Are you sure that "LED" refers the correct pin? Does the LED work at all?
I am actually not in front of my computer to confirm but I think you might be right, I might not have set pinMode(LED, OUTPUT)
As for the pin referring to, I am sure, I check twice and yes the LED works, I manually tested it against 3v and gnd and it was working.
I will check tonight the pinMode
Thanks for the fast reply
goldriver2:
I am actually not in front of my computer to confirm but I think you might be right, I might not have set pinMode(LED, OUTPUT)
That's one of the reasons the forum posting rules say to post the whole sketch, not just the part where you think the problem might be.
Also says to stick the sketch in code tags, the </> icon top left of the typing pane.
Noted, as a new user I admit that I did not read the rules, I will and I will adhere to them
Sorry and thanks for the help