/* This is an example code for the SN754410 H-BRIDGE motor controller from PCBGadgets This example code is in the public domain. */ // define motor1 control pins on Arduino Uno board. int M1_EN = 9;//motor 1 enable (EN pin) int M1_L1 = 10;//motor 1 logic pin1 ( L1 pin) int M1_L2 = 11;//motor 1 logic pin2 ( L2 pin) // Pwm variable Max value = 255 int speed_value=200; // the setup routine runs only once when you reset the microcontroller. void setup() { // initialize the digital pin as an output. pinMode(M1_EN, OUTPUT); pinMode(M1_L1, OUTPUT); pinMode(M1_L2, OUTPUT); } // the loop routine runs forever: void loop() { // enable motor1 analogWrite(M1_EN, speed_value); // set motor1 logic1 (L1) and logic2 (L2) pins to turn the motor in one direction digitalWrite(M1_L1, HIGH); digitalWrite(M1_L2, LOW); // wait 3 seconds delay(3000); //turn the motor the other direction by reversing L1 and L2 pins digitalWrite(M1_L1, LOW); digitalWrite(M1_L2, HIGH); delay(3000); }