Program Delayed

One of our teams is having trouble with their program. When they drive, the motors are delayed a few seconds. Another problem they are having is that when they move their stick the slightest bit, the robot turns almost a complete 90 degrees and it is way too much. I am 100% sure it is the program because I downloaded mine to the controller and it worked perfectly fine. Thanks for the help!

Hello!
Is it possible for you to send the code? If you are uncomfortable making it public you can dm me with the code, make sure to use ``` on both ends of the code to format it!

Thanks!

1 Like

We found what was messing it up, it was this code for the pneumatics. But now we don’t know where to put this code. Anywhere we put it, it does not work. The pneumatics code worked before when it was in the code that it was messing up.

if (Controller1.ButtonA.pressing())
Indexer.set(false);
wait(0.5, sec);
Indexer.set(true);
if (Controller1.ButtonB.pressing())
Endgame.set(true);
else
Endgame.set(false);

Going off what it is, it needs to be put in a forever loop, but I need to see your code to be 100% sure of that. You can make use of threads to do that.

One problem I see with your code is that it has the wait(0.5, sec) command. This will pause your whole driver control program for 0.5 seconds every time the code loop runs.

Also, I don’t know if you copied the code wrong, but your first if statement doesn’t have braces around the 3 statements. This essentially makes the code

if (Controller1.ButtonA.pressing()) {
    Indexer.set(false);
}
wait(0.5, sec);
Indexer.set(true);

instead of

if (Controller1.ButtonA.pressing()) {
    Indexer.set(false);
    wait(0.5, sec);
    Indexer.set(true);
}

This means your program will pause for 0.5 seconds every loop, instead of only when Button A is pressed.

If you are going to send more code, please use the ``` like Blaziumm said to make it easier for others to read.

2 Likes