Draw yourself a flowchart of what you what to happen.
The code will depend a little on what version of pBasic you’re using. In 2002 there was an if-then statement but no if-then-else. 2003 introduced the if-then-else, so nowadays it’s easier to code up.
Turning off the motors when in high gear would look something like:
Code:
pwm1 = p1_y
pwm2 = p1_y
pwm3 = p1_y
If gear < High then skipit
pwm2 = 127
pwm3 = 127
skipit:
Make sure the victors are in coast though, otherwise, you'll be trying to drag rather than roll the rear wheels around.
For steering I imagine you’d want to force your potentiometer reading to match your joystick steering axis (making sure the pot is mechanically at 127 when the wheel is straight forward. Here is a simple way, but you'd have to play with the values for pwm4 so it didn't turn too quickly, overshoot, and start thrashing back n forth.
P.S. It's also nice to have some mechanical drag on the steering, so it holds it's position a little and isn't just waggling loosely.
Code:
pwm4 = 127
If pot < p1_x then pwm4 = 100
If pot > p1_x then pwm4 = 155
A more sophisticated control would use the difference between where you want to be (p1_x) and where it currently is (pot) to slow down the steering motor as p1_x and pot get close. For example, pwm4 = (p1_x - pot) * 5 / 10, where you'd play with the value 5/10 until you slowed the response so it wouldn't overshoot and thrash. Just be aware of how pBasic deals with negative numbers.