Code, robots and stuff

So I decided to write a library for controlling H-bridge-connected motors for the Arduino enviroment. Here's an url to it. For now I'm just calling it "Motor" until I can think of something better. There are (as of yet, more are planned) three function calls; Forward, Reverse and Coast. The names are self explanatory. Example:

/*



   Example motor-control code by Gabriel Fornaeus

   More information at http://hax0r.se



 */



// Set ledPin

int ledPin = 13;

// Motor control

#include 

motor left(6, 7);

motor right(5, 4);



void setup() {

    // Initialize the LED pin as an output:

    pinMode(ledPin, OUTPUT);      

    }



void loop(){



    // Set LED on

    digitalWrite(ledPin, HIGH);

    // Drives forward at 58% speed

    left.Forward(150);

    right.Forward(150);

    // Coasts for one second

    left.Coast();

    right.Coast();

    delay(1000);

    /* PWM-breaking applied for 500 milliseconds 

     (this can cause high current drain, make sure your transistors can handle it)

     */

    left.Reverse(3);

    right.Reverse(3);

    delay(1000);

    // Spin

    left.Reverse(100);

    right.Forward(100);

    delay(500);

    // Coasts for one second

    left.Coast();



    // Turn LED off and wait for one second

    digitalWrite(ledPin, LOW);

    delay(1000);



}


Simple, right?