-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMy-Arduino-Project.ino
86 lines (84 loc) · 1.93 KB
/
My-Arduino-Project.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
int ledRed = 3;
int ledOrange = 4;
int ledYellow = 6;
int ledGreen = 8;
int red = 11;
int green = 10;
int blue = 9;
int comp = 7;
int time1 = 200;
int time2 = 1;
int time3 = 1000;
int n = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(ledRed, OUTPUT);
pinMode(ledOrange, OUTPUT);
pinMode(ledYellow, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(comp, INPUT);
}
void loop() {
if(digitalRead(comp) == HIGH) {
while(digitalRead(comp) == HIGH) {
digitalWrite(LED_BUILTIN, HIGH);
}
digitalWrite(LED_BUILTIN, LOW);
n++;
if(n > 3) {
n = 0;
}
}
switch(n) {
case(0):
digitalWrite(ledRed, HIGH);
delay(time1);
digitalWrite(ledRed, LOW);
digitalWrite(ledOrange, HIGH);
delay(time1);
digitalWrite(ledOrange, LOW);
digitalWrite(ledYellow, HIGH);
delay(time1);
digitalWrite(ledYellow, LOW);
digitalWrite(ledGreen, HIGH);
delay(time1);
digitalWrite(ledGreen, LOW);
break;
case 1:
digitalWrite(ledRed, HIGH);
digitalWrite(ledOrange, HIGH);
digitalWrite(ledYellow, HIGH);
digitalWrite(ledGreen, HIGH);
delay(time1);
digitalWrite(ledRed, LOW);
digitalWrite(ledOrange, LOW);
digitalWrite(ledYellow, LOW);
digitalWrite(ledGreen, LOW);
delay(time1);
break;
case 2:
digitalWrite(red, HIGH);
delay(time1);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(time1);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
delay(time1);
digitalWrite(blue, LOW);
break;
case 3:
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
delay(time2);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
digitalWrite(green, LOW);
delay(time3);
break;
}
}