Motor Shield V2 with Potentiometer for 2 DC motors

Hi,


connect the potentiometer to the Arduino as shown in the picture above and use the following code

[code]// Demo function:The application method to drive the DC motor.
// Author:Frankie.Chu
// Date:20 November, 2012

#include “MotorDriver.h”

void setup()
{
/Configure the motor A to control the wheel at the left side./
/Configure the motor B to control the wheel at the right side./
motordriver.init();
Serial.begin(9600);

}

void loop()
{

    int speed=analogRead(0); // read the Analog port AO
    speed = speed >> 2; // go from 10 bits(1023) to 8 bits(255) 
    motordriver.setSpeed(speed,MOTORB);
motordriver.setSpeed(speed,MOTORA);

    Serial.print("MotorSpeed = ");
    Serial.println(speed);

    motordriver.goForward();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goBackward();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goLeft();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goRight();
delay(2000);
motordriver.stop();
delay(1000);

}[/code]

Let us know if you need any other information.

Thanks and Regards
MotorDriver.zip (4.26 KB)