![]() |
Turning a button into a switch
I have worked with LabView for three years or so now but have recently joined an FTC team. We are using RobotC as the programming language on this team.
My question is, how can I turn a button into a switch? The functionality of this button would essentially cause the robot to enter a different mode. Even if you don't quite now how to do it in RobotC, I can use the fundamental idea and translate it. Thanks!! -Noob Programmer :D |
Re: Turning a button into a switch
Create a variable that holds the mode that robot is in. (IE 1 = tall mode, 2 = short mode, etc...) Then when you hit the button it would run a set if statements to check what mode it is in and switch that variable to the other value(s). Finally the rest of the code would look to that variable which would determine the mode it is in.
|
Re: Turning a button into a switch
You also need a check to keep from rapidly toggling while the button is held momentarily.
A check that requires releasing and pressing the button again for it to toggle. e.g., Code:
if (button == true & button /= previous_button_state) |
Re: Turning a button into a switch
One might want to wait longer than two cycles; the loop timing matters. The way kids play video games theses days, de-bouncing the drivers is important.
|
| All times are GMT -5. The time now is 02:43. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi