Test program for Dagu Arduino Mini Driver board and two motors

The program starts with the setup section.The Left Motor direction is controlled by pin 7 of the Dagu board and its speed by pin 9.  The Right Motor direction is on pin 8 the speed by pin 10. So first those pin numbers are defined and then they are set for output.  In the drive forward section the direction pins are set LOW and the speed is set to max i.e. value of 255. To drive the motors in the opposite direction then the direction pins would be set to HIGH. The turn is achieved by reversing the direction of the Right motor while keeping the left motor driving forward.

// Test program for Dagu Arduino Mini Driver board and two motors.
//Drives robot in a square. Derived from Dawn robotics original.
const int LEFT_MOTOR_DIR_PIN = 7;
const int LEFT_MOTOR_PWM_PIN = 9;
const int RIGHT_MOTOR_DIR_PIN = 8;
const int RIGHT_MOTOR_PWM_PIN = 10;

const int DRIVE_FORWARD_TIME_MS = 1500;
const int TURN_TIME_MS = 300;
// ——————————————
void setup()
{
// Setup the pins
pinMode( LEFT_MOTOR_DIR_PIN, OUTPUT );
pinMode( LEFT_MOTOR_PWM_PIN, OUTPUT );
pinMode( RIGHT_MOTOR_DIR_PIN, OUTPUT );
pinMode( RIGHT_MOTOR_PWM_PIN, OUTPUT );

}
//———————————————
void loop()
{
// Drive Forwards at 100%
digitalWrite( LEFT_MOTOR_DIR_PIN, LOW );
digitalWrite( RIGHT_MOTOR_DIR_PIN, LOW );
analogWrite( LEFT_MOTOR_PWM_PIN, 255 );
analogWrite( RIGHT_MOTOR_PWM_PIN, 255 );
delay( DRIVE_FORWARD_TIME_MS );

Leave a Reply