This is my first time trying to program a toggle in PROS and it doesn’t fully work. The mech expands but then doesn’t contract and I don’t know why. Please help.
What I see happening is the first IF statement would set the toggle to TRUE, but then toggle would be set to TRUE for the second IF statement causing the second IF statement to always run.
You can fix this by using an ELSE statement
In addition to this, you are using master.get_digital(), which is more suited for buttons that you hold down (it is constantly returning true due to the loop). master.get_digital_new_press() is the function that allows toggle buttons, since it adds a timeout so that it doesn’t constantly return true.
I did both of these thing and when I tried the mech wouldn’t even expand. I don’t really know what the issue was but I tried a lot of different arrangements including putting them separately.
You also put return;
at the end of your if statements, which returns from opcontrol
, stopping your program entirely. Also, PROS 4 has cylinder.toggle()
so you don’t need this anyway (it looks like you are using PROS 3 though but I would recommend switching).