Hello,
I am having trouble getting my motors to move at all using an arduino motor shield
I am attempting to build an autonomous robot using the following components:
1.) Arduino Uno
2.) Sainsmart motor shield (Amazon)
3.) Pirate 4wd platform (Amazon)
5.) PING ultrasonic sensor (Amazon)
6.) QTI sensor (Amazon)
According to the included documentation, the motor specs are:
No-load current (3v): 60mA
No-load current (6v): 71 mA
Stall current (3V): 260 mA
Stall current (6V): 470 mA
Torgue (3V): 1.2kgcm
Torgue (6V): 1.92kgcm
So far, I have attached the motor shield to the arduino and plugged the arduino into a computer through usb and performed tests on the PING and QTI sensors using pins A2-A5 (pins supposedly not used by the motor shield) This worked fine and all sensors performed as expected.
Next, I hooked up 5 rechargable AA batteries (Amazon) to the external power screw terminals on my motor shield and connected the two wires from one of my motors to the two M1 slots on the motor screw terminal. I also removed the jumper connecting the power from the arduino to the shield.
Following are pictures of the setup (please pardon the quality):
I tried the adafruit DCMotorTest example that is recommended for the shield:
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
controlFor use with the Adafruit Motor Shield v2
----> Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit [v2.3] : ID 1438 : Adafruit Industries, Unique & fun DIY electronics and kits
*/#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Adafruit Motorshield v2 - DC Motor test!");AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz// Set the speed to start, from 0 (off) to 255 (max speed)
myMotor->setSpeed(150);
myMotor->run(FORWARD);
// turn on motor
myMotor->run(RELEASE);
}void loop() {
uint8_t i;Serial.print("tick");
myMotor->run(FORWARD);
for (i=0; i<255; i++) {
myMotor->setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
myMotor->setSpeed(i);
delay(10);
}Serial.print("tock");
myMotor->run(BACKWARD);
for (i=0; i<255; i++) {
myMotor->setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
myMotor->setSpeed(i);
delay(10);
}Serial.print("tech");
myMotor->run(RELEASE);
delay(1000);
}
Nothing happened. At first, the serial output would just outpu "Adafruit" and then nothing more. I then removed all of the sensors (PING and QTIs on A2-A5) and the serial output started working. However, though the output windows kept cycling between tick/tock/tech as expected, the motors didn't move at all. They made no rotations, no noise, no twitching, nothing. I attempted to connect more AAs ((getting up to 12) but it seemed to make no difference.
Can anyone provide insight as to why the motors are not working at all? or as to why the sketch wouldn't work when the sensors were plugged in? Any help would be much appreciated.
Thank you for your time.