Using a motor driver with an MEGA168 (Help Please)

As part of learning some circuitry I decided to build a small autonamous robot. Nothing special, just “If distance to object in front >= 2 feet, turn left 90 degrees, go forward, REPEAT” Only problem is I don’t understand the tables that sparkfun carries on them. I was wondering if anyone could point me towards a good driver for this. http://www.sparkfun.com/commerce/produc … cts_id=319 and hopefully point out how to use it. IE: How to wire it up, and a bit of sample code for forward, reverse, stop. I’m sure I can just edit from there. Any help would be REALLY appreciated.

I’ve got one of those but haven’t used it yet. If you want reverse you will need an H-bridge; things start getting complicated and you are in for a lot of studying. You might be able to manage with a couple of relays, if constant speed is OK.

Leon

Really I suppose constant speed would be good, but that probably wouldn’t be that great for turning. Relays would be the alternative though.

striker121:
Really I suppose constant speed would be good, but that probably wouldn’t be that great for turning. Relays would be the alternative though.

An H-bridge for each motor is the proper way to do it, with PWM.

Leon

I recently went down this road and i’d be happy to explain how to do it. Using all Sparkfun parts (yay!)

Arduino: http://www.sparkfun.com/commerce/produc … cts_id=666

Motor driver: http://www.sparkfun.com/commerce/produc … ts_id=8905

Motors: http://www.sparkfun.com/commerce/produc … cts_id=319

Tank treads: http://www.sparkfun.com/commerce/produc … cts_id=321

I controlled mine via Xbee but you could program it however you want.

The only hard part is wiring up the Motor driver. Picture from official sparkfun listing

http://www.sparkfun.com/commerce/images … 5-02-L.jpg

ok, top/left side is all inputs. PWM+IN1+IN2 will drive one motor. Just make sure PWMs are connected to an arduino PWM line like Digital IO 10/11. IN1 & IN2 are normal digital IO lines. GND is the ground from your arduino. STBY is basically your on/off switch, i use Digital IO pin 13 because of the built in led.

Bottom/right side is mostly outputs. VCC&GND is from the arduino (power and ground). VMOT/GND is from your external power source to drive the motors, i’m using 2x 9v batteries in a series. O1/O2 goes to one motor.

Ok, on to using it. I’m going to use example pins, you are free to use whatever.

Motor #1, Direction pins 6 & 7 (6 on, 7 off = foward, switch for reverse)

Motor #2, Direction pins 8 & 9

Motor #1 Speed pin is 10

Motor #2 Speed pin is 11

So, set STBY pin 13 HIGH. Set pins 6 & 8 HIGH for forward motion. Finally set Speed pins both to 40 (mid-low speed). That’s it… you’re moving.

Here’s some fuzzy pictures of mine

http://i4.photobucket.com/albums/y104/t … CN0861.jpg

http://i4.photobucket.com/albums/y104/t … CN0859.jpg