I’m trying to code our robot in VEX IQ code blocks which is simple, but when I use the block When Controller Button R Up Pressed it will only run the code underneath the block once. If I click the button again later without stopping and restarting the program it won’t have any effect. Does anybody know how to fix this? Thanks
You’re using exact degrees for motor positions, which is terribly inaccurate.
Instead, do something like:
if lift position in degrees < 15 then
doStuff
if lift position in degrees > 730 then
doOtherStuff
Okay, trying it out right now, thanks!
I tried it and it fixed the previous problem but now when I click the button it repeats the code inside both if statements every time.
It’s possible that the robot is not sensing the angle right. Or maybe you should put something in between that clearly separates the two statements.
@A380125 @Noah10851B
I was actually able to fix this. I made some really stupid mistakes like the order of the two if/then statements (the first one changed the angle so that it matched the second) and adding set lift position to 0 degrees at the end of the 2nd if/then statement (this would make the first one repeat again when I next clicked it) Thanks for the help though!
I wouldn’t ever set the angle once the program is started. Where the bot starts is zero and then let it be. At the end you are spinning it to position 700 and making that your new zero? If this is an arm I don’t know how that’s going to produce what you want.
I was just messing around actually, I only spent a few minutes on this program. I put in some blocks that I was going to change later like the set to zero one and I should have realized that it would affect the program.