Button problem

I have a very big problem. In Blynk application I have one button. In arduino program in loop all the time I am reading state of that button. And problem is here: If my button is ON (1) when I start ma Arduino reading is 0 and there is no power like that is OFF(0) in Blynk. Than I click button to set state to OFF and then reading is also 0 (thats need to be 0) and then when I change from OFF to ON reading is good, and reads like ON (1). Why in the start reading is 0 until I change button 2 times. Please help that is very big project for me. Thank you

To be honest, it’s impossible to understand your problem from the information that you’ve posted. However, this jumped out at me…

If you link your button widget to a virtual pin (let’s say V1) then the function BLYNK_WRITE(V1) would be triggered each time the button is pressed.
Take a look at the Sketch Builder for some examples:

Pete.

I tried that too, but same problem. Always on start thar button is 0. I tried virtual, analog, digital and same problem. Any other solutionns?

Ok, maybe you don’t understand but independently of button state on the start button reading is 0. If the button is OFF on start reading is 0, if the button is ON reading is 0. If button is OFF on the start you need to click one time and button will be on 1 but if the button on the start is ON reading is 0, then you need to click to OFF (one more time reading is 0) and finnaly when you changed to ON second time reading will be 1. I don’t know how to explain when problem is retarded. I asked a lot of guys and there were a lot of solutions but nothing weren’t helpful. Give other suggestions. Thank you!

Read this:
http://docs.blynk.cc/#blynk-firmware-blynktimer-blynksyncvirtualvpin

Pete.

Follow Pete’s answer as I think that your only “problem” is that you don’t sync the pins…
Use this:
BLYNK_CONNECTED() { Blynk.syncAll(); }
and I believe you’ll be good…
Otherwise, post your code…

I added BLYNK_CONNECTED() Blynk.syncAll(); } adn all work, really thank you!

2 Likes