How do I write code so that when I push the joystick up and left at about 45 degrees, the robot turns left forward? Push the joystick up and right at about 45 degrees, the robot turns right forward. Push the joystick down and right at about 45 degrees, the robot turns right backward. Push the joystick down and left at about 45 degrees, the robot turns left backward.

if (joystick is up and joystick is left at about 45 degrees){ robot turns left forward}if (joystick is up and joystick is right at about 45 degrees){ robot turns right forward}if (joystick is down and joystick is left at about 45 degrees){ robot turns left backward}if (joystick is down and joystick is right at about 45 degrees){ robot turns right backward}

Well assuming you have 2x DC motors driven through an h-bridge which allows PWM of the motor speeds.... And assuming the Esplora joystick which I've never used, works just like any other 2 axis, 2 potentiometer joystick, giving analog voltages based on position.

Read the two pots to determine the position of the stick... you might need to do some Serial.print stuff to see what voltages are produced at various positions to calibrate. Depending on the readings that will give your quadrant, which will trigger your "if"s.

Then in each "if", PWM the motors to give the desired angle. (After some messing around to find what speeds give what angle calibration, eg forward left might be left motor 1/4 speed, right motor 3/4 speed or whatever.)

I found out from http://arduino.cc/en/Reference/EsploraReadJoystickX that the joystick on Esplora gives readings from -512 to 512 with 0 at center position. Let's say that I move the joystick up and right at about 45 degrees. The readings could be about 256 on both axis. How do I code the if test? Something like this in BASIC:

I got the code working when I push the joystick in desired direction, waiting until the robot moves, and releasing the joystick. Now, if I want to hold the joystick in desired direction as long as I want, the robot has a pause in the walking cycle. I want to use do/while loop but how can I do that?