Hello! I am trying to control 2 separate DC motors via the Seeedstudio Motor Shield V2 and 2 potentiometers (one to control each motor) connected to open analog ports on my UNO. Getting some odd behavior from the motors, though.
What I want: I want to be able to adjust the speed of the motor on channel 0 by twisting pot. A, and simultaneously adjust the speed of the motor on channel 1 by twisting pot. B.
What I'm getting: When I twist pot. A on, motor on channel 0 sits motionless and makes an odd clicking sound. Pot. B does nothing alone, but when I turn both potentiometers up, motor on channel 0 starts moving EXTREMELY fast, while the motor on channel 1 does not move.
The code I'm trying to use:
#include "MotorDriver.h"
MotorDriver motor;
int velocityA;
int velocityB;
void setup() {
motor.begin();
}
void loop() {
// Read values from my 2 potentiometers
// connected to Analog 0 and Analog 3
int potValA = analogRead(A0);
int potValB = analogRead(A3);
// Convert the input range of the potentiometers
// to the output range of the Motor Shield V2
velocityA = map(potValA, 0, 1023, 0, 100);
velocityB = map(potValB, 0, 1023, 0, 100);
// Run the motor on channel 0 and the motor
// on channel 1 at their respective speeds
motor.speed(0, velocityA);
motor.speed(1, velocityB);
delay(2);
}
I've also tried the above code with a serial monitor, and the potVal and velocity values appeared to be correct.
I am not sure what I'm doing wrong, as I've looked the seeedstudio wiki page up and down, and found nothing.
I would greatly appreciate it if someone could help and/or provide a solution! Thank you!
---Wolfram1914