-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoccerBot.ino
75 lines (72 loc) · 1.93 KB
/
soccerBot.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
int motorRightA = 8; //Right Motor-clockwise
int motorRightB = 9; //Right Motor-anticlockwise
int motorLeftA = 11; //Left Motor-clockwise
int motorLeftB = 10; //Left Motor-clockwise
char bt = 0; //Bluetooth Control
void setup()
{
pinMode(motorRightA, OUTPUT);
pinMode(motorRightB, OUTPUT);
pinMode(motorRightB, OUTPUT);
pinMode(motorLeftB, OUTPUT);
Serial.begin(9600);
}
void loop(){
control();
}
// All the Controls of the Soccer Bot
void control() {
if (Serial.available() > 0)
{
bt = Serial.read();
if (bt == 'F') //move forwards
{
digitalWrite(motorRightA, HIGH);
digitalWrite(motorLeftA, HIGH);
digitalWrite(motorRightB,LOW);
digitalWrite(motorLeftB,LOW);
}
else if (bt == 'S') //stop!
{
digitalWrite(motorRightA, LOW);
digitalWrite(motorRightB, LOW);
digitalWrite(motorLeftA, LOW);
digitalWrite(motorLeftB, LOW);
}
else if (bt == 'R') //right
{
digitalWrite(motorRightA, LOW);
digitalWrite(motorRightB, LOW);
digitalWrite(motorLeftA, HIGH);
digitalWrite(motorLeftB, LOW);
}
else if (bt == 'L') //left
{
digitalWrite(motorRightA, HIGH);
digitalWrite(motorRightB, LOW);
digitalWrite(motorLeftA, LOW);
digitalWrite(motorLeftB, LOW);
}
else if (bt == 'I') //forward right
{
digitalWrite(motorRightA, HIGH);
digitalWrite(motorRightB, LOW);
digitalWrite(motorLeftA, LOW);
digitalWrite(motorLeftB, HIGH);
}
else if (bt == 'G') //forward left
{
digitalWrite(motorRightA, LOW);
digitalWrite(motorRightB, HIGH);
digitalWrite(motorLeftA, HIGH);
digitalWrite(motorLeftB, LOW);
}
else if (bt == 'B') //move backwards
{
digitalWrite(motorRightB, HIGH);
digitalWrite(motorLeftB, HIGH);
digitalWrite(motorRightA,LOW);
digitalWrite(motorLeftA,LOW);
}
}
}