Motor Shield V2 with Potentiometer for 2 DC motors

Ardiuno Compatible shields

Moderators: lily.li, violet

Post Reply
kcpstudio
Pre-kindergarten
Pre-kindergarten
Posts: 1
Joined: Tue Apr 26, 2016 10:36 am

Motor Shield V2 with Potentiometer for 2 DC motors

Post by kcpstudio » Tue Apr 26, 2016 10:54 am

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

kavi
Staff
Staff
Posts: 305
Joined: Tue Dec 09, 2014 12:06 pm

Re: Motor Shield V2 with Potentiometer for 2 DC motors

Post by kavi » Tue Apr 26, 2016 5:05 pm

Hi,
AnalogReadSerial_BB.png
connect the potentiometer to the Arduino as shown in the picture above and use the following code

Code: Select all

//  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);
	
}
Let us know if you need any other information.

Thanks and Regards

Post Reply