I currently use the Cortex Microcontroller, and my code has no problems at all. However, when I try and press the corresponding buttons for the motors, they don’t move at all. I believe it has to do with the Firmware, but I could be wrong. I currently do not have the code on me right now, but I would be happy to post it.
I would also like to include which buttons on the controller work:
Please do post your code. I’d be happy to take a look at it.
Are you using the latest version of ROBOTC, version 2.32? The latest firmware files are included in it, so I’d recommend updating ROBOTC and the various firmware files on your joystick and Cortex.
When using if-else statements (even a long string of them like in your code), only one of the sections/branches of code gets run. The section that gets run is the first that has a condition that is “true”.
In your code, your first check is if Btn5U is pressed. The third check is if Btn5U is released. One of these scenarios will **always **be true, so the code below the third check will **never **be run.
There’s two ways of solving this problem:
You could break your long sequence of if-else statements into multiple smaller sequences.
You could re-arrange your logic to avoid checking if a button is pressed, and then released, preventing it from going through your conditions.
I’m still having a little trouble understanding what you meant by “making my long sequence into multiple smaller ones”. I’m fairly new at RobotC as this is only my first year programming for my team. Also, I don’t understand about re-arranging my logic.