How to Decode Logic Errors

Everyone on my team wants me to program a function where you press the B button once, and the block stacker moves forward to ~90 degrees. Press it again and it moves back to collecting position. So I naturally thought, easy-peasy. And once again I was proven wrong by those stupid logic errors that I can never seem to decode. Is there a way that I can get around these logic errors easily, maybe a certain method of finding them?

The easiest way for me to track down logic errors is printing variables at certain points in the code to check them.

Also if you are multitasking make sure different programs aren’t overriding each other.

I do that, and everything seems to be running fine according to that, but it does not do what i tell it to do

Compilation errors are shown in the ‘output’ tab in VEXcode. Be sure to read the entire contents of the tab to get the full detail of the errors.

If you’d like help debugging existing code, please post it here (remember to wrap it in [code]...[/code] tags for formatting, otherwise it’s very difficult to debug code you can’t see.

they are not, I fixed that problem

If (buttonpressed and cooldownFinished){
    If (up){
1 Like

You can try to get the degrees of the tray. If the tray is out, go in. If the tray is in, go out.

1 Like