Driving DC motors with Adafruit motor shield V1.1
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 12
- Joined: Mon Jan 21, 2013 5:21 pm
Driving DC motors with Adafruit motor shield V1.1
How do I find or write code to run 4 small DC motors at one time?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Driving DC motors with Adafruit motor shield V1.1
We have not manufactured or sold the V1.1 shield for several years now. Where did you purchase your shield?
-
- Posts: 12
- Joined: Mon Jan 21, 2013 5:21 pm
Re: Driving DC motors with Adafruit motor shield V1.1
I purgchased the Motor Shield Kit v1.1 from Makershed.com in Dec 2012
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Driving DC motors with Adafruit motor shield V1.1
Hmmm. MakerShed should have the V1.2 boards. Can you post a photo of the board?
- arctic_eddie
- Posts: 233
- Joined: Tue Feb 28, 2012 6:01 pm
Re: Driving DC motors with Adafruit motor shield V1.1
I have a motor shield kit in my hand that I bought last year. The package says V1.1 with a web link:
http://adafruit.com/products/81
This shows a photo of your latest kit but it shows V1.0. My board is not the same as your photo and says V1.2.
What is the latest version?
http://adafruit.com/products/81
This shows a photo of your latest kit but it shows V1.0. My board is not the same as your photo and says V1.2.
What is the latest version?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Driving DC motors with Adafruit motor shield V1.1
1.2 is the latest version. It should be a blue board. Sounds like maybe the package labeling is a source of confusion. The product description should be updated too.
Thanks Arctic_Eddie!
Thanks Arctic_Eddie!
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Driving DC motors with Adafruit motor shield V1.1
Back to the original question:
You need to declare 4 different motors, one for each of the motor channels. Then you can command each motor by name.How do I find or write code to run 4 small DC motors at one time?
Code: Select all
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motor1.setSpeed(200);
motor2.setSpeed(200);
motor3.setSpeed(200);
motor4.setSpeed(200);
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
void loop()
{
uint8_t i;
Serial.print("tick");
motor1.run(FORWARD);
motor2.run(BACKWARD);
motor3.run(FORWARD);
motor4.run(BACKWARD);
for (i=0; i<255; i++)
{
motor1.setSpeed(i);
motor2.setSpeed(i);
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}
}
-
- Posts: 12
- Joined: Mon Jan 21, 2013 5:21 pm
Re: Driving DC motors with Adafruit motor shield V1.1
My board is blue but the package says v1.1. I tried to post a picture but It did not post. I will try again. I uploaded the code that you suggested and got motors 1 and 2 to run but not motors 3 and 4. Your help is much appreciated in getting me headed in the right direction.
-
- Posts: 12
- Joined: Mon Jan 21, 2013 5:21 pm
Re: Driving DC motors with Adafruit motor shield V1.1
Hopefully, these pictures will post this time
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Driving DC motors with Adafruit motor shield V1.1
OK. That is a 1.2 board. The version number is printed just above the M1,M2 motor terminal block. You have the L293D for M3-M4 installed backwards. The notch needs to line up with the one on the silkscreen.
-
- Posts: 12
- Joined: Mon Jan 21, 2013 5:21 pm
Re: Driving DC motors with Adafruit motor shield V1.1
I re-installed the L293D correctly but motors 3 & 4 still did not work . I then rotated the two to make sure it was not damaged, but I still get the same result. I really appreciate your time, suggestions and prompt replies.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Driving DC motors with Adafruit motor shield V1.1
It is hard to see in the photos, but you have a few solder joints that appear a little 'solder-starved' - including a couple of pins on that L293D. Take a close look and touch up any joints that look suspicious.
http://learn.adafruit.com/adafruit-guid ... n-problems
http://learn.adafruit.com/adafruit-guid ... n-problems
Please be positive and constructive with your questions and comments.