I am trying to run a simple motor code on my adruino with a adafruit motor shield. I have installed the afmotor to my library. However no matter what code i use including the example code on the AFMotor library I keep getting the same error. It says AF-DC MOTOR DOES NOT HAVE A NAME TYPE.
Here is the sample code I am currently trying to use. Please help.
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
AF_DCMotor motor(4);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motor.setSpeed(200);
motor.run(RELEASE);
}
void loop() {
uint8_t i;
Serial.print("tick");
motor.run(FORWARD);
for (i=0; i<255; i++) {
motor.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor.setSpeed(i);
delay(10);
}
Serial.print("tock");
motor.run(BACKWARD);
for (i=0; i<255; i++) {
motor.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor.setSpeed(i);
delay(10);
}
Serial.print("tech");
motor.run(RELEASE);
delay(1000);
}
Programming problem with my motorshield
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Programming problem with my motorshield
Sounds like the library is not properly installed. Check the library tutorial: http://www.ladyada.net/library/arduino/libraries.html
-
- Posts: 4
- Joined: Sun Nov 07, 2010 6:02 pm
Re: Programming problem with my motorshield
I checked my library and it shows the AFMotor in there ? After looking at the link you sent on libraries it seems like it is correct but I am not sure. How would I knoew if it was in the right spot ?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Programming problem with my motorshield
What OS are you running and where was your library installed?
-
- Posts: 4
- Joined: Sun Nov 07, 2010 6:02 pm
Re: Programming problem with my motorshield
Windows 7.
Library is installed in my library folder inside the arduino IDE
Library is installed in my library folder inside the arduino IDE
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Programming problem with my motorshield
Older versions of the Arduino IDE had the library directories in the IDE folder. For more recent versions of the Arduino IDE, libraries should be installed in your document folder:
C:\Users\<user name>\Documents\Arduino\Libraries
C:\Users\<user name>\Documents\Arduino\Libraries
Please be positive and constructive with your questions and comments.