I am trying to test the motor shield. I am using an Arduino Uno. 2 DC Motors. One 9V battery to power the motor shield + Arduino. The code is the following, which is supposed to run the motors alternatively. The thing is that nothing happens. All the led are ON, for the motor shield and Arduino.
Does anyone have an idea, what am I doing wrong?
#include <AFMotor.h>
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);
void setup()
{
// Start up serial connection
Serial.begin(9600); // baud rate
Serial.println("Motor test!");
Serial.flush();
}
void loop()
{
Serial.print("tick");
motor1.setSpeed(200);
motor1.run(FORWARD); // turn it on going forward
delay(1000);
Serial.print("tock");
motor1.setSpeed(200);
motor1.run(BACKWARD); // the other way
delay(1000);
Serial.print("tack");
motor1.run(RELEASE); // stopped
delay(1000);
Serial.print("tick");
motor2.setSpeed(200);
motor2.run(FORWARD); // turn it on going forward
delay(1000);
Serial.print("tock");
motor2.setSpeed(200);
motor2.run(BACKWARD); // the other way
delay(1000);
Serial.print("tack");
motor2.run(RELEASE); // stopped
delay(1000);
}
A standard (not Alkaline) 9volt battery can barely power an Uno without all the rest, and only for a very short time.
I would say that the author of that article did not know what he/she was doing.
Leo..
Allright, so I may have to add a second 9V battery for the Arduino. I was just not sure that I could power them both in the same time. I did not want to get some smoke out of the Arduino or motor shield. This only for testing. Then, I should consider probably some lithium battery.
I've been using a 12 volt power supply for a pc. they are about $20 -$30 but they are reliable and adjustable.
I found that 9 volts are a little unpredictable and can over heat or discharge very easily. they also dont last very long at all.
I used one for a small project and kept it in a box. when I reached into the box to pull everything out, the battery had overheated and kind of exploded with out anything being on.