Need help with libraries

Hi. I can’t seem to get a sketch for a little robot to connect with with my motor shield library file.

I’m using a Sainsmart L293 motor shield and the AMotorC driver but can’t seem to get the sketch to find the file; can anyone suggest what I need to add to the sketch to let it find the driver?

Thanks.

Below is the sketch:

#include <AMotorC.h>

#define trigPin 12 // define the pins of your sensor
#define echoPin 13
AF_DCMotor motor1(1,MOTOR12_64KHZ); // set up motors.
AF_DCMotor motor2(2, MOTOR12_8KHZ);

void setup() {
Serial.begin(9600); // begin serial communitication
Serial.println(“Motor test!”);
pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
motor1.setSpeed(105); //set the speed of the motors, between 0-255
motor2.setSpeed (105);
}

void loop() {

long duration, distance; // start the scan
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // delays are required for a succesful sensor operation.
digitalWrite(trigPin, HIGH);

delayMicroseconds(10); //this delay is required as well!
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;// convert the distance to centimeters.
if (distance < 25)/*if there’s an obstacle 25 centimers, ahead, do the following: */ {
Serial.println (“Close Obstacle detected!” );
Serial.println (“Obstacle Details:”);
Serial.print (“Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!”);// print out the distance in centimeters.

Serial.println (" The obstacle is declared a threat due to close distance. “);
Serial.println (” Turning !");
motor1.run(FORWARD); // Turn as long as there’s an obstacle ahead.
motor2.run (BACKWARD);

}
else {
Serial.println (“No obstacle detected. going forward”);
delay (15);
motor1.run(FORWARD); //if there’s no obstacle ahead, Go Forward!
motor2.run(FORWARD);
}

Hi Shawnarama,

Welcome to the forum.

I'm using a Sainsmart L293 motor shield and the AMotorC driver but can't seem to get the sketch to find the file ;

Would it be possible to provide a copy of the error message that the IDE is providing ?
What version of Arduino IDE are you using ?
Are you using a Uno ?

Did the manufacturer provide the library in ZIP format ?
Did you install the library using the "add a .ZIP library method" ?

In the future, it might be best to use THE "code" tags". You will find more on this at :
http://forum.arduino.cc/index.php/topic,148850.0.html

This will help our experts read/import the code in a proper format...

dan

#include <AMotorC.h>



#define trigPin 12 // define the pins of your sensor
#define echoPin 13
AF_DCMotor motor1(1,MOTOR12_64KHZ); // set up motors.
AF_DCMotor motor2(2, MOTOR12_8KHZ);

I am absolutely certain that the AF_DCMotor class is NOT defined in a header file called AMotorC.h.

Use the proper name for the header file. If you still have problems, post the error messages exactly, not some hand-waving “I think I seem to have a vague recollection that part of the message might have been…” crap.