Go Down

Topic: Button for two functions (Read 158 times) previous topic - next topic

martinius96

Hey there, i have this sketch at circuits.io to simulation. I need to control 2 voids with one button.
I need. If i click button first time there will be active code of void spustenie. If i click on it again, it will skip to void vypnutie.
If there will be void vypnutie as actual and if i click on button, no reaction. If i click on button when void spustenie is active, auto skip to void vypnutie.
Code with simulation online here:CIRCUITS.IO

Grumpy_Mike

Quote
I need to control 2 voids with one button.
What are voids? Do you mean functions? In C++ a void is the type of variable a function returns. Void meaning no variable is returned.
So lets assume you mean two functions.

First off you should post you code properly here read How to use this forum to find out how. If you want to post an image see image guide

Now to your problem. Look at the examples menu off the file menu. The 02Digital menu off that has an example of the code you need, it is called state change detection. Use that to hold a number of 1 or 2 depending on the number of times you have pressed the button. Then use an if ... else statement on that number to call one of your two functions.

Go Up