Rookie programmer here! So i wanted to code a 6 wheel drive train directly powered by 6 motors. I wanted to make one analog control vertical motion, and the other for turning. I’ve got two if statements for turning left and right, but the code only seems to execute whatever is 2nd in order…
Here’s what i have so far:
#include "main.h"
void operatorControl() {
while (1) {
delay(20);
int x = joystickGetAnalog(1,3);
int y = joystickGetAnalog(1,1);
if (y<-15){
motorSet(2,x);
motorSet(3,x);
motorSet(4,x);
motorSet(5,-y);
motorSet(6,-y);
motorSet(7,-y);
}
else {
motorSet(2,x);
motorSet(3,x);
motorSet(4,x);
motorSet(5,x);
motorSet(6,x);
motorSet(7,x);
}
if (y > 15){
motorSet(2,y);
motorSet(3,y);
motorSet(4,y);
motorSet(5,x);
motorSet(6,x);
motorSet(7,x);
}
else{
motorSet(2,x);
motorSet(3,x);
motorSet(4,x);
motorSet(5,x);
motorSet(6,x);
motorSet(7,x);
}
}
}
I’ve tried switching the order of the if statements and the opposite would happen on the bot. Why is this happening and how can I get both sides of the drive to work?
Thanks!