It’s supposed to move forward for 5 counts, turn around, resent the count, and repeat, but the code won’t even start. I compiled multiple times and it shows to compiler errors, can someone help?
Welcome, can you give us the Compiler Errors? Next time to get a faster response follow these steps - Help us help you
This looks like RobotC. If I remember right the code to run the motors with a Cortex brain is the following.
//The motors should be defined at the top
#pragma config(Motor, port1, RightMotor, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port10, LeftMotor, tmotorVex393_HBridge, openLoop, reversed)
//To make them spin use:
motor(RightMotor) = 60;
motor(LeftMotor) = 60;
2 Likes
Put your movement code in a while True loop.
2 Likes
Does your task main have a closing curly bracket? }
The brain only runs through your code once.
count = 0
if count < 5:
Brain says:Yes, count < 5; continue on
start motors
wait 2 seconds
count = count+1
Brain says:count = 1
else:
Brain says:if was true; not running else; skip else
- Brain says:
end of program
Try using a loop; a forever loop.
count = 0
while (true) {
if (count < 5) {
start motors;
wait(2);
}
else {
spin motors back;
wait(10);
count = 0;
}
}
8 Likes
Thank you! this helped me a lot
I hope you understood the logic and didn’t just copy the code? If you don’t think through the code, you won’t learn anything for next time.