Virtual pin does not toggle led

I’m out of here. Good luck!


Thanks for the assistance, Pete.

Do a search on the forum for code examples for basic tasks and study it.

I have done my research on other codes here. I have come to the conclusion that a button cannot perform two tasks simultaneously. So i use one button to turn on the physical led and the other to snap the servo in place. It kinda sucks cause’ the project would have been cooler if one button could perform the task.

That is so wrong

1 Like

So help me figure it out. What did i miss? the led will only flash for a millisecond before going off when i use a virtual pin but it stays on when i use a physical pin like GPIO16.

I will pseudo code and leave to you to write the code.
On your app install 1 button and allocate a virtual pin, choose which mode you want the switch to work.
In your code declare your physical LED pin and Servo Pin and a variable name for the button.

Create a :
Button variable name = param.asInt();
If (the button ==1) //button is high
DigitalWrite the led HIGH
Do stuff with servo
More actions here if needed
DigitalWrite led LOW
Do other stuff with servo
more actions here if needed