I am currently working on a line following robot and I am trying to use the Adafruit Motor Shield Library. I have installed it manually, using the Arduino library, nothing is working. I have even checked the file location and everything seems good. Could someone please help? I am using the Arduino Uno R3 and the L293D Motor Drive Shield
The topic title indicates your library was not findable by the IDE. Post your sketch here using the < CODE > button to format it. "Manually" to me means you put it in the wrong place. Use the IDE to install the library.
You may have checked things and they may look good to you, but you are going to have to show us before anyone can help you. We can't see what you see.
Show us that there is an AFMotor directory in your sketchbook/libraries directory tree.
Show us that there are other libraries in the same spot that you can successfully use.
Show us the contents of the AFMotor directory tree.
I am new to arduino, so could you please help me how to provide a directory tree?
//ARDUINO LINE FOLLOWING CAR//
// YOU HAVE TO INSTALL THE AFMOTOR LIBRARY BEFORE UPLOAD THE CODE//
// GO TO SKETCH >> INCLUDE LIBRARY >> ADD .ZIP LIBRARY >> SELECT AF MOTOR ZIP FILE //
//including the libraries
#include <AFMotor.h>
//defining pins and variables
#define left A0
#define right A1
//defining motors
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);
void setup() {
//declaring pin types
pinMode(left,INPUT);
pinMode(right,INPUT);
//begin serial communication
Serial.begin(9600);
}
void loop(){
//printing values of the sensors to the serial monitor
Serial.println(digitalRead(left));
Serial.println(digitalRead(right));
//line detected by both
if(digitalRead(left)==0 && digitalRead(right)==0){
//Forward
motor1.run(FORWARD);
motor1.setSpeed(150);
motor2.run(FORWARD);
motor2.setSpeed(150);
motor3.run(FORWARD);
motor3.setSpeed(150);
motor4.run(FORWARD);
motor4.setSpeed(150);
}
//line detected by left sensor
else if(digitalRead(left)==0 && !analogRead(right)==0){
//turn left
motor1.run(FORWARD);
motor1.setSpeed(200);
motor2.run(FORWARD);
motor2.setSpeed(200);
motor3.run(BACKWARD);
motor3.setSpeed(200);
motor4.run(BACKWARD);
motor4.setSpeed(200);
}
//line detected by right sensor
else if(!digitalRead(left)==0 && digitalRead(right)==0){
//turn right
motor1.run(BACKWARD);
motor1.setSpeed(200);
motor2.run(BACKWARD);
motor2.setSpeed(200);
motor3.run(FORWARD);
motor3.setSpeed(200);
motor4.run(FORWARD);
motor4.setSpeed(200);
}
//line detected by none
else if(!digitalRead(left)==0 && !digitalRead(right)==0){
//stop
motor1.run(RELEASE);
motor1.setSpeed(0);
motor2.run(RELEASE);
motor2.setSpeed(0);
motor3.run(RELEASE);
motor3.setSpeed(0);
motor4.run(RELEASE);
motor4.setSpeed(0);
}
}
This is my test code found from: DIY Builder
Showing directories and files has nothing to do with Arduino. That's just basic computer operations.
"...Documents\Arduino\libraries\Adafruit_Motor_Shield_library" It is located in this folder.
Please show a screenshot of the file manager with contents of this directory
What's libraries folder in the the library itself? - it shouldn't be there
I fixed the problem, my documents folder was apparently moved around after a while. I restored it to its default location and everything works now.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
