Go Down

Topic: Lego motor not working with motor shield (Read 674 times) previous topic - next topic



I'm trying to connect two lego motors to arduino using a motor shield. The motors are supposed to run on 9V each so I've tried boosting the voltage by connecting two 9V batteries to the vin on the screw terminals as well as by connecting a cable to the arduino itself. Nothing seems to be working, if I hold an LED to the pins connecting to the shield they light up as they should with the programme. Here is my code:
Code: [Select]
void setup() {
  pinMode(12,OUTPUT); // a forward/backward
  pinMode(13,OUTPUT); // b forward/backward
  pinMode(11,OUTPUT); //a speed
  pinMode(3,OUTPUT); //b speed

void loop() {
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);

(so basically a variation on the blink preset)

Any suggestions would be greatly appreciated, thanks!


May 06, 2016, 02:32 am Last Edit: May 06, 2016, 02:33 am by alka
What motor shield are you using?

From the code it seems you might be toggling the direction pin on and off without actually giving it a speed (pwm on 3 or 11).

Go Up