/** * Prototype * Arduino Duemilanove * L298N shield V03 * * Pin 13 = motor A or coil A + * Pin 12 = motor A or coil A – * Pin 11 = motor B or coil B + * Pin 10 = motor A or coil A enable * Pin 9 = motor B or coil B enable * Pin 8 = motor B or coil B – **/ #define Apos 13 #define Aneg 12 #define Aenable 10 void setup() { pinMode(Apos, OUTPUT); pinMode(Aneg, OUTPUT); pinMode(Aenable, OUTPUT); } void loop() { clockwise(); set_speed(50); delay(5000); brake(); delay(2000); counter_clockwise(); set_speed(100); delay(5000); brake(); delay(2000); } //input value from 0 to 255 void set_speed (int val){ analogWrite(Aenable, val); } void clockwise(){ digitalWrite(Apos, HIGH); digitalWrite(Aneg, LOW); } void counter_clockwise(){ digitalWrite(Apos, LOW); digitalWrite(Aneg, HIGH); } void brake (){ digitalWrite(Aenable, LOW); } /** * Vex = higher voltage that can power the motor and/or the shield as well as the Arduino if wanted * 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself * GND = ass always, the ground of everything * B- = Connection of the first motor or first winding of the stepper motor * B+ = Connection of the first motor or first winding of the stepper motor * A- = Connection of the second motor or second winding of the stepper motor * A+ = Connection of the second motor or second winding of the stepper motor **/