1#include<Servo.h>
2#include<SoftwareSerial.h>
3
4SoftwareSerial BT(12,13);
5char currstatus;
6Servo lift;
7Servo front;
8Servo rear;
9
10void setup() {
11currstatus='s';
12Serial.begin(9600);
13BT.begin(9600);
14
15lift.attach(10);
16rear.attach(9);
17front.attach(11);
18
19lift.write(90);
20rear.write(90);
21front.write(90);
22delay(2000);
23}
24
25void forward() {
26 lift.write(120);
27 delay(100);
28
29 front.write(60);
30 rear.write(90);
31 delay(100);
32
33 lift.write(90);
34 delay(100);
35
36 lift.write(60);
37 delay(100);
38
39 front.write(90);
40 rear.write(120);
41 delay(100);
42
43 lift.write(120);
44 delay(100);
45}
46
47void backward() {
48
49 lift.write(120);
50 delay(100);
51
52 front.write(120);
53 rear.write(150);
54 delay(100);
55
56 lift.write(90);
57 delay(100);
58
59 lift.write(60);
60 delay(100);
61
62 front.write(90);
63 rear.write(120);
64 delay(100);
65
66 lift.write(90);
67 delay(100);
68
69
70}
71
72void Stop() {
73front.write(120);
74delay(100);
75lift.write(120);
76delay(100);
77rear.write(90);
78delay(100);
79}
80
81void loop() {
82
83 Serial.println("looping...");
84 while(BT.available())
85 {
86 currstatus=BT.read();
87 Serial.println(currstatus);
88 }
89
90 if(currstatus=='w')
91 {
92 forward();
93 Serial.println("fwd");
94 }
95
96if(currstatus=='b')
97 {
98 backward();
99 Serial.println("fwd");
100 }
101
102if(currstatus=='s')
103 {
104 Stop();
105 Serial.println("fwd");
106 }
107
108
109}