Arduino 2 DC motor control nunchuck

Hi,

I should control 2 metal (12V) motors (pololu #1105) with Dual VNH2SP30 Motor Driver with arduino and nunchuck. I’m a quite newbie when it comes to electronics.My problem is that the engines do not start when I move Nunchuck. The code used is as follows.

int InA1 = 7;
int InB1 = 8;
int PWM1 = 3;  //PWM1 connects to pin 3
int PWM1_val = 127; //(25% = 64; 50% = 127; 75% = 191; 100% = 255)

void setup() {
  Serial.begin(9600);
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
  pinMode(PWM1, OUTPUT);
}

void loop() {
    digitalWrite(InA1, HIGH);
    digitalWrite(InB1, LOW);
    analogWrite(PWM1, PWM1_val);
}

I can advise, help in this regard? Thanks you very much.
Sorry for my bad english, isn’t my native language.


Hello.

I don’t see anything immediately wrong with your wiring. What kind of DC power supply are you using? Can it source enough current to drive your motors at that duty cycle? Have you tried starting at a lower duty cycle? Have you verified that the Arduino’s 5V regulator can supply enough current to power the VNH3 chips and the Nunchuck at the same time? One good strategy is to try to make your setup as simple as possible to isolate the misbehaving part. Do you have an oscilloscope?

- Ryan

Hi Ryan,
Thanks for your quick response. I followed your advice and I increased the current to 0.2 A (at12 V) from DC power supply , I had the surprise to see that one metal motor started. I am so happy. I think should connect and PWM, 1Na, 1Nb pins on VNH2SP30 to start and the second motor , I modified corresponding source code. I don’t know how to modified the code to move the Nunchuck and the motors start to rotate in clockwise and counter-clockwise direction. Thank you very much for your technical support.
Cheers,
Valentin

You’re going to need a lot more than 0.2 A if you want to get the full performance out of motor #1105 (67:1 Metal Gearmotor 37Dx54L mm). Quoting from the top of the product page:

–David