-
Notifications
You must be signed in to change notification settings - Fork 0
/
Project_Code.ino
74 lines (63 loc) · 2.07 KB
/
Project_Code.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
char t;
void setup() {
pinMode(13,OUTPUT); //left motors forward
pinMode(12,OUTPUT); //left motors reverse
pinMode(11,OUTPUT); //right motors forward
pinMode(10,OUTPUT); //right motors reverse
pinMode(9,OUTPUT); //Led
Serial.begin(9600);
}
void loop() {
if(Serial.available()){
t = Serial.read();
Serial.println(t);
}
if(t == 'F'){ //move forward(all motors rotate in forward direction)
digitalWrite(13,HIGH);
digitalWrite(11,HIGH);
}
else if(t == 'B'){ //move reverse (all motors rotate in reverse direction)
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
}
else if(t == 'L'){ //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)
digitalWrite(11,HIGH);
}
else if(t == 'R'){ //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)
digitalWrite(13,HIGH);
}
else if(t == 'W'){ //turn led on or off)
digitalWrite(9,HIGH);
}
else if(t == 'w'){
digitalWrite(9,LOW);
}
else if (t == 'Q') { // move forward while turning left
digitalWrite(13, HIGH); // left motors forward
digitalWrite(11, HIGH); // right motors forward
delay(100); // adjust this delay to control the turning rate
digitalWrite(13, LOW); // turn off left motors briefly to create turning effect
delay(50); // adjust this delay to control the turning rate
}
else if (t == 'E') { // move forward while turning right
digitalWrite(13, HIGH); // left motors forward
digitalWrite(11, HIGH); // right motors forward
delay(100); // adjust this delay to control the turning rate
digitalWrite(11, LOW); // turn off right motors briefly to create turning effect
delay(50);
}
else if (t == 'X') { //drift Right
digitalWrite(13,HIGH);
digitalWrite(10,HIGH);
}
else if (t == 'Y') { //drift Left
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
}
else if(t == 'S'){ //STOP (all motors stop)
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
}
}