Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modularise code with functions #3

Open
bogsnork opened this issue Apr 25, 2019 · 0 comments
Open

modularise code with functions #3

bogsnork opened this issue Apr 25, 2019 · 0 comments

Comments

@bogsnork
Copy link
Owner

from: @nogirvine :

I think what you are doing here is fine, I would be tempted here to us else if for putting servos relating to button1state to some other position if == LOW. Eg. your return positions when the pin goes low could be put in the else if rather than the whole sequence running on one button push perhaps.
Then use a new if statement to determine state for button2state.
I would be tempted, rather than write each action here for each button push, to build separte functions for the control of the servos TL, BL,TR, BR, which were passed variables from the button pushing code. Should half the amount of overall code and allow you to write more complex scenarios for multiple button pushes more easily. Build these below where void loop(); finishes and then call them form in the void loop(); part.
some stuff on the internet about it such as this http://forum.arduino.cc/index.php?topic=1881.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant