0% found this document useful (0 votes)
10 views3 pages

New Rich Text Document

Uploaded by

favioslopez85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

New Rich Text Document

Uploaded by

favioslopez85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

<AFMotor.

h>

AF_DCMotor motor(1);

#include <AFMotor.h>

#define x A0

#define y A1

#define Speed 180

AF_DCMotor motor1(3);

AF_DCMotor motor2(4);

#include <AFMotor.h>

#define x A0

#define y A1

#define Speed 180

AF_DCMotor motor1(3);

AF_DCMotor motor2(4);

void setup() {

Serial.begin(9600);

motor1.setSpeed(Speed);

motor2.setSpeed(Speed);

}
void loop() {

int X = analogRead(x);

int Y = analogRead(y);

Serial.print(X);

Serial.print("\t");

Serial.println(Y);

if (X >= 800) {

motor1.run(BACKWARD);

motor2.run(BACKWARD);

} else if (X <= 200) {

motor1.run(FORWARD);

motor2.run(FORWARD);

} else if (Y >= 800) {

motor1.run(FORWARD);

motor2.run(BACKWARD);

} else if (Y <= 200) {

motor1.run(BACKWARD);

motor2.run(FORWARD);

} else {

motor1.run(RELEASE);

motor2.run(RELEASE);

You might also like