-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch_aug09a.ino
69 lines (66 loc) · 1.49 KB
/
sketch_aug09a.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
int p1 = 7;
int p2 = 6;
int p3 = 12;
int p4 = 11;
void setup() {
// put your setup code here, to run once:
pinMode(p1, OUTPUT);
pinMode(p2, OUTPUT);
pinMode(p3, OUTPUT);
pinMode(p4, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
char control = Serial.read();
if (control == 'F') {
digitalWrite(p1, HIGH);
digitalWrite(p2, LOW);
digitalWrite(p3, HIGH);
digitalWrite(p4, LOW);
delay(2000);
digitalWrite(p1, LOW);
digitalWrite(p3, LOW);
delay(1000);
}
else if (control == 'B') {
digitalWrite(p1, LOW);
digitalWrite(p2, HIGH);
digitalWrite(p3, LOW);
digitalWrite(p4, HIGH);
delay(2000);
digitalWrite(p2, LOW);
digitalWrite(p4, LOW);
delay(1000);
}
else if (control == 'R') {
digitalWrite(p1, LOW);
digitalWrite(p2, HIGH);
digitalWrite(p3, HIGH);
digitalWrite(p4, LOW);
delay(2000);
digitalWrite(p2, LOW);
digitalWrite(p3, LOW);
delay(1000);
}
else if (control == 'L') {
digitalWrite(p1, HIGH);
digitalWrite(p2, LOW);
digitalWrite(p3, LOW);
digitalWrite(p4, HIGH);
delay(2000);
digitalWrite(p1, LOW);
digitalWrite(p4, LOW);
delay(1000);
}
else{
digitalWrite(p1, LOW);
digitalWrite(p2, LOW);
digitalWrite(p3, LOW);
digitalWrite(p4, LOW);
delay(2000);
// digitalWrite(p2, LOW);
// digitalWrite(p4, LOW);
// delay(1000);
}
}