I have a float switch attached to my Arduino and already have an if statement to turn on a plug socket when it changes state. I also want an LED on Blynk to come on but can’t seem to find the right way of coding it. Can you help?
The command is led2.setValue(); for intensity and led2.on(); led2.off(); to turn it on and off.
And Blynk.setProperty(V2, “color”, BLYNK_RED); for the custom colour.
This assumes you have defined BLYNK_RED as a HEX value: #define BLYNK_RED "#D3435C"
Otherwise this will work as well: Blynk.setProperty(V2, “color”, “#D3435C”);
Thanks for your reply. I had tried that and just did again and it is still not working. The arduino PIN 13 is working but the LED on Blynk is not coming on.
You have everything running thousands of times a second in your void loop(), so what is probably happening is flood errors and delays. Break everything out but the blynk.run() and add in a timer.run() then put your sensor reads, pin writes and led commands in a timed loop.
Thanks for the advice. However will this timer continue to trigger events even if Blynk goes offline? Eg. The Arduino become unconnected with the network/server? I need some functions to continue as timed even if Blynk gets disconnected.
I thought I did post it properly. I highlight the code and then click the ‘code’ button. Is they not write?
Generally Blynk IoT works best when online and talking to all it’s components (APP ↔ SERVER ↔ HARDWARE), however there are ways of coding “offline” hardware operation and even reconnection with different commands, but they do seem best suited for the ESP/WiFi device and connection types.
But as long as the sketch is not stuck at the “trying to connect” state then yes, all timers and loops in your sketch will keep working.
Unfortunately that <Preformatted Text> button method doesn’t always display C++ code in a clean and properly highlighted way, thus the three backticks and initial “cpp” method at the beginning, followed by three more backticks at the end, ensures proper visuals… as directed in the initial Welcome Topic, that most people ignore the first time and never see again