-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEskyBot.ino
55 lines (46 loc) · 1.05 KB
/
EskyBot.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <SoftwareSerial.h>
#include <AFMotor.h>
SoftwareSerial BTSerial(14, 15); //RX, TX
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
int val;
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
}
void loop() {
if (BTSerial.available() > 0){
val = Serial.read();
if (val == 'a'){ //Forwards
Serial.println("Forward");
motor1.setSpeed(200);
motor2.setSpeed(200);
motor1.run(FORWARD);
motor2.run(BACKWARD);
}
if (val == 'b'){ //Right
Serial.println("Right");
motor1.setSpeed(200);
motor2.setSpeed(0);
motor1.run(FORWARD);
}
if (val == 'c'){ //Backwards
Serial.println("Backward");
motor1.setSpeed(200);
motor2.setSpeed(200);
motor1.run(BACKWARD);
motor2.run(FORWARD);
}
if (val == 'd'){ //Left
Serial.println("Left");
motor1.setSpeed(0);
motor2.setSpeed(200);
motor2.run(BACKWARD);
}
else {
Serial.println("Stopped");
motor1.run(RELEASE);
motor2.run(RELEASE);
}
}
}