Hello everyone, Last time i posted an Topic i got great help that worked, so thank you for that!
The guy that helped me also redirected me to another topic about momentairy Switching with Blynk
But unfortunately it (and other topics) dont work for me. I dont know what i am doing wrong, therefore i write this Topic
First of all i will tell you a little about the project
I am trying to make a system so when i say to my Google Assistant that i should turn on the computer
Then the NodeMCU will be a momentairy switch that will emulate a button that will be pressed for 1 second and then automatically turn off
The problem i have is that when i say to google it will turn on and never turn off again which is a problem, it should automatically turn off after 1 second or so
I think it was probably me that pointed you towards a possible solution.
To be honest, this is not a Blynk issue, but without some information about what youâve tried and why it didnât work, itâs difficult for anyone to do more than I did and signpost you toward potential solutions.
Post the code that youâre having problems with (correctly formatted of course) along with the error message youâre getting, and weâll take a look at it.
//===== Timeed latching button =====
BLYNK_WRITE(V1) { // Button Widget set as switch
latchButton = param.asInt();
if (latchButton == 1 && latchFlag == 0) {
latchFlag = 1; // Keeps from allowing button press more then once while relay activated
// ----- Start your timed thing here
digitalWrite(5, HIGH); // Activate digital pin
// -----
timer.setTimeout(5000L, { // Timed Lambda Function - Latching Button release after 5 seconds
// ----- Stop your timed thing here
digitalWrite(5, LOW); // Deactivate digital pin
// -----
Blynk.virtualWrite(V1, 0); // Reset Latching Button to OFF
latchFlag = 0; // resets to allow next interaction
}); // END Timer Function
} else {
if (latchButton == 0 && latchFlag == 1) { // If you try to tun off the button before time is up
Blynk.virtualWrite(V1, 1); // Restore Latching Button ON until timer is finished
}
}
}
C:\Users\mathi\AppData\Local\Temp\arduino_modified_sketch_679240\ESP8266_Standalone.ino: In function âvoid BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)â:
ESP8266_Standalone:27:5: error: âtimerâ was not declared in this scope
timer.setTimeout(5000L, []() { // Timed Lambda Function - Latching Button release after 5 seconds
^
exit status 1
âtimerâ was not declared in this scope
Iâve been looking around in other topics
So with your help and others i was beginning to understand it. and now i accomplished my goal of turning it on momentarily. to turn on my computer.