/* The Makerbase H-Bridge Motor Controller is a common motor controller that can be used to control the direction and speed of a DC motor using PWM. Here's an example of how you can use it with an Arduino: This script will make the motor turn in one direction for a second, stop for a second, then turn in the opposite direction for a second, and then stop again. This cycle repeats indefinitely. Please adjust the pin numbers and rest of the code according to your exact setup and requirements. Also, remember to connect the GND of the motor driver to the GND of the Arduino, and to supply the driver with an appropriate power source. */ // Define pin connections & motor's states const int motorPin1 = 9; // Pin connected to Motor Driver's Input 1 const int motorPin2 = 10; // Pin connected to Motor Driver's Input 2 void setup() { // Sets the two pins as Outputs pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); } void loop(){ // Drive the motor clockwise digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); delay(1000); // Wait for 1 second // Stop the motor when motorPin1 & motorPin2 are HIGH or LOW digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, HIGH); delay(1000); // Wait for 1 second // Drive the motor counterclockwise digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); delay(1000); // Wait for 1 second // Stop the motor when motorPin1 & motorPin2 are HIGH or LOW digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, HIGH); delay(1000); // Wait for 1 second }