FORWARD AND BACKWARD MOTOR

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
mnguyen14
 
Posts: 1
Joined: Tue Apr 24, 2012 7:11 pm

FORWARD AND BACKWARD MOTOR

Post by mnguyen14 »

I want to make my robot to move forward and backward. I've installed AFMotor in the libraries correctly (I think). It was shown under sketch--> Import Libraries--> AFMotor. Here is my code. The error said that : "Delay was not declared in this scope" and all kind of DigitalWrite, HIGH, LOW, etc... are not declare in this scope.
Can someone please help me figure out what is wrong? Did I miss anything?



#include <AFMotor.h>

AF_DCMotor motor1(3); // Motor 1 is connected to the port 1 on the motor shield
AF_DCMotor motor2(5); // Motor 2 is connected to the port 2 on the motor shield

void AllForward() { // Makes the robot go forward
motor1.run(FORWARD); // Motor 1 goes forward
motor2.run(FORWARD); // Motor 2 goes forward
}

void Rotate()
{
motor1.run(BACKWARD); // Motor 1 goes forward
motor2.run(FORWARD); // Motor 2 goes backward
delay(1600); // Time required to rotate
}

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: FORWARD AND BACKWARD MOTOR

Post by Franklin97355 »

That is not Arduino code. Can you include your entire program inside "code" tags?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: FORWARD AND BACKWARD MOTOR

Post by adafruit_support_bill »

Can you include your entire program
Also, what version of the IDE and what operating system you are using.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”