Go Down

Topic: Arduino MotorShield V1, need clarification (Read 277 times) previous topic - next topic

Arielis

Hey,

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?
Code: [Select]

#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);
   
   
}

vinceherman

Can you show us your wiring.  A picture of the project and a picture of a hand drawn diagram are both helpful.

Wawa

One 9V battery to power the motor shield + Arduino.
Is that a smoke alarm battery?

Arielis

Yes, that's a smoke alarm battery.

I've been following this tutorial, http://www.instructables.com/id/Adafruit-Motor-Shield-Tutorial/, so it would be the same wiring.


although I modified the code as I've got only 2 DC motors.

I always start with a basic step which is to run the motor.

Wawa

#4
May 18, 2017, 11:36 pm Last Edit: May 18, 2017, 11:37 pm by Wawa
Yes, that's a smoke alarm battery.

I've been following this tutorial, http://www.instructables.com/id/Adafruit-Motor-Shield-Tutorial/, so it would be the same wiring.
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..


Arielis

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.

Thanks

Kurenai

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.

be careful with those things.

edgemoron

#7
May 21, 2017, 12:28 am Last Edit: May 21, 2017, 12:42 am by edgemoron
Get youself a 6 AA batt holder and 6 rechargeable NIMH AAs + a wall charger.
https://www.adafruit.com/product/248
This comes in handy as well:
https://www.adafruit.com/product/1328

Go Up