2 motors one joystick help

I was wondering if any one could provide code that would work for a robot that is being made with components such as an arduino uno rev 3, USB Host Shield 2.0, seeed motor shield, a wireless xbox 360 controller receiver, and an xbox 360 controller.

This robot is using two motors to drive it and they need to be able to vary in speed for turning, probably using a throttle gain difference when moving the joystick.

There is unlikely to be someone prepared to write you a turnkey solution*: works best here if you try first and then ask for specific help if you get stuck.

The seeed shield uses an L298, and their wiki shows the pin numbers it uses.

Looks to me like for motor on channel 0 as they call it, you need to make Arduino pins 8 and 11 opposite to each other ie hi/low will be one direction and low/hi the other. Then you need to pwm pin 9 for speed.

Similar for the other motor channel 1 which is pins 12 and 13 for direction, 10 for speed.

Start with that, just analogWrite()-ing some value to the pwm pins to see if it works, or even just digitalWrite() them high.

Then have a look here to see how to pwm based on a pot's input and instead of an led, that will be your motor speed pins 9 and 10.

Disclaimer: I'm going off this- you should read it yourself. YMMV.

  • that said, money can change hands here.