I am building an arcade drive robot and I cannot figure out what my errors are. I am a bit of a noob, but I know enough to write a code and some basic debugging. Each time I fix an error, I run into a new one. here’s the code:
void setup(int x, int y); //make joystick arcade style controller
int powY;
int powX;
int powRightMotor;
int powLeftMotor;
int powmotordriveright;
int powmotordriveleft;
void loop()
{
// convert joystick -128 to 127 range to -100 to 100 for powering motors
powY = (y * 100) / 127; //joystick y axis gives maximum power level
powX = (x * 100) / 127; //x axis determines which motor is reduced or
//reversed for a turn
if (powX < 0) //if x negative, turning left; otherwise, turning right
powLeftMotor = (powY * (100 + (2 * powX))/100); //left motor reduced for right turn
powRightMotor = (powY * -(100 + (2 * powX))/100); //right motor is reversed
else
powRightMotor = (powY * (100 - (2 * powX))/100); //right motor reduced for left turn
powLeftMotor = (powY * -(100 + (2 * powX))/100); //left motor reversed
powRightMotor = powmotordriveright;
powLeftMotor = powmotordriveleft;
}
here are the current errors:
MOTOR.ino: In function ‘void loop()’:
MOTOR:13: error: ‘y’ was not declared in this scope
MOTOR:14: error: ‘x’ was not declared in this scope
MOTOR:23: error: ‘else’ without a previous ‘if’
Yes, there may be obvious problems so please no hate messages!