Hi to all,
Because of my robot project, I created a simple library for H bridges like the L293, you can get the library from http://dl.dropbox.com/u/5218310/arduino/L29x.zip
This is my first Arduino library, if you have suggestions, please leave them in this topic. Thank you.
Regards,
Luis Sismeiro
From the README.txt
L29x Arduino Library
--------------------
This is a library to simplify the use of H bridges in you sketches. You
need to configure the Arduino pins that are connected to the H bridge
according to their functions.
For example we connect an L293 driving two motors to the Arduino Uno.
This are the pins used:
L293 ------------- Arduino
--------------------------
1,2EN ------------ 2
1A --------------- 3 (PWM)
2A --------------- 4
3,4EN ------------ 6 (PWM)
3A --------------- 7
4A --------------- 8
We start declaring the two motors:
L29x motorOne(3, 2, 4);
L29x motorTwo(6, 7, 8);
That's it for the setup part. Then we use the methods available:
stop() - 1,2A with zero, 1A and 2A LOW
rotPos(byte pwm) - 1,2A with PWM, 1A LOW and 2A HIGH
rotNeg(byte pwm) - 1,2A with PWM, 1A HIGH and 2A LOW
For example, to start the motors fast in one direction:
motorOne.rotPos(255);
motorTwo.rotPos(255);
To stop both motors:
motorOne.stop();
motorTwo.stop();
That's it, I hope you find this library useful in your own sketches.
20120114 Luis Sismeiro