Another coding issue

VexRiseAboveTeamwork (5).pdf (12.1 MB)
No idea why certain issues are happening. When I click R down the first one works fine (bottom lift to 200 degrees) but when I click it again the lift goes down, the midclaw goes down, but then the midclaw goes back up a few seconds later and the scissorclaw never closes. Another problem is for R up the first 2 commands work but when I get to the third one when the lift is at its highest nothing happens. Please respond with any ideas as to why this is happening, thank you

Sorry about the download, the file was too big.

Sometimes when working with code like this, it’s a good idea to also print some output so you can see what’s going on. Here’s a small program that implements the same finite state machine that you are trying to use.


When this program is run, the output seen follows the following sequence
press 1 -> R Down 0
press 2 -> R Down 1
press 3 -> R Down 20
press 4 -> R Down 1
press 5 -> R Down 20

so there’s some issues in the logic, it doesn’t follow the 0, 1, 2, 0 sequence that I think you wanted.

The problem is that when down is 2, the first if statement executes and sets down to 0, but the if statement testing for down to be 0 is also executed, and that then sets down to be 1.

You probably want to change that code so only one conditional executes every time you press R down.
one solution would be



Thank you! I’m trying this out for both R up and R down right now will let you know if it works

Ok, so I used the print option and I was able to find where the code stopped. It still did the same issues for both statements after I changed it to the if else blocks. The brain only printed up to 3.

Did some further testing and was able to able to get it to do the scissorclaw statement and it printed 4. However, the midclaw still moved forward again a few seconds after 4 was printed which I don’t know why. I am further testing so I will probably find more problems and fix them soon.

Ok, thank you! I was able to figure out wait went wrong using the print block. The code now works