-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBluetooth_Connection.ino
103 lines (92 loc) · 1.67 KB
/
Bluetooth_Connection.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
void Bluetooth_Connection(){
if(command == 'F'){
Forward();
Read_Data();
}
if(command == 'G'){
Backward();
Read_Data();
}
if(command == 'H'){
Left();
Read_Data();
}
if(command == 'I'){
Right();
Read_Data();
}
if(command == 'E'){
ForwardLeft();
Read_Data();
}
if(command = 'O'){
ForwardRight();
Read_Data();
}
if(command == 'M'){
BackLeft();
Read_Data();
}
if(command == 'N'){
BackRight();
Read_Data();
}
if(command == 'P'){
Stop();
Read_Data();
}
}
void Forward(){
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
}
void Backward(){
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(255);
motor2.run(BACKWARD);
}
void Left(){
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
}
void Right(){
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(BACKWARD);
}
void Stop(){
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
}
void ForwardLeft(){
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(255);
motor2.run(FORWARD);
}
void ForwardRight(){
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(0);
motor2.run(RELEASE);
}
void BackLeft(){
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(255);
motor2.run(BACKWARD);
}
void BackRight(){
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(0);
motor2.run(RELEASE);
}