Motor Shield V2 with Potentiometer for 2 DC motors

Hi Guys,

Im hoping one of you could help me. First, I’m new here and enjoying all the wonderful write ups you all are doing. Please keep it up because it all truly helps people like me understand writing code and hooking up devices.

With that said… I have a situation and could use your help. I have a Arduino UNO connected to a Seeed Motor Shield V2. I have two DC motors hooked up. Now… the motors are rated at 19 Volts. However, I’m running 12 Volts into the boards which isn’t an issue considering I need to control the speeds with a POT anyway. It would be nice to keep the torque of these motors but doing so would mean staying close to their rated volts which in turn… increases their speeds. So, that won’t work for me.

I need to get these two motors to spin at around 70 RPMs but I need the ability of quick/easy adjustments like…via a POT. I was told pulsing the 12 volts would keep the torque vs killing the volts via a POT. This is beyond me. I’m still learning as much as I can in my free time but work is always taking my free time.

Can anyone help me with this. Suggest a way to do “pulses”? or just outline how I should hook up a pot? I’m going to assuming that one pin go to say Analog 0, another pin to 5V, and the last pin to ground. If that’s correct, I still need help with the code.

Thanks

Hi,
AnalogReadSerial_BB.png
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)