1
2const int LED_red = 8;
3const int LED_blue = 11;
4int buzzerPin = 9;
5int tiltPin = 10;
6
7void setup() {
8
9
10 pinMode(LED_blue, OUTPUT);
11 pinMode(LED_red, OUTPUT);
12 pinMode(buzzerPin, OUTPUT);
13 pinMode(tiltPin, INPUT_PULLUP);
14
15
16 digitalWrite(LED_red, LOW);
17 digitalWrite(LED_blue, LOW);
18 digitalWrite(buzzerPin, LOW);
19
20}
21
22void loop() {
23
24 if (digitalRead(tiltPin) == HIGH) {
25 digitalWrite(buzzerPin, HIGH);
26 digitalWrite (LED_red, HIGH);
27 digitalWrite (LED_blue, LOW);
28 delay (250);
29 digitalWrite (LED_red, LOW);
30 digitalWrite (LED_blue, HIGH);
31 delay (250);
32 digitalWrite (LED_red, HIGH);
33 digitalWrite (LED_blue, LOW);
34 delay (250);
35 digitalWrite (LED_red, LOW);
36 digitalWrite (LED_blue, HIGH);
37 delay (250);
38 digitalWrite (LED_red, HIGH);
39 digitalWrite (LED_blue, LOW);
40 delay (250);
41 digitalWrite (LED_red, LOW);
42 digitalWrite (LED_blue, HIGH);
43 delay (250);
44 digitalWrite (LED_red, HIGH);
45 digitalWrite (LED_blue, LOW);
46 delay (250);
47 digitalWrite (LED_red, LOW);
48 digitalWrite (LED_blue, HIGH);
49 delay (250);
50 digitalWrite (LED_red, HIGH);
51 digitalWrite (LED_blue, LOW);
52 delay (250);
53 digitalWrite (LED_red, LOW);
54 digitalWrite (LED_blue, HIGH);
55 delay (250);
56 digitalWrite (LED_red, HIGH);
57 digitalWrite (LED_blue, LOW);
58 delay (250);
59 digitalWrite (LED_red, LOW);
60 digitalWrite (LED_blue, HIGH);
61 delay (250);
62 digitalWrite (LED_red, HIGH);
63 digitalWrite (LED_blue, LOW);
64 delay (250);
65 digitalWrite (LED_red, LOW);
66 digitalWrite (LED_blue, HIGH);
67 delay (250);
68 digitalWrite (LED_red, HIGH);
69 digitalWrite (LED_blue, LOW);
70 delay (250);
71 digitalWrite (LED_red, LOW);
72 digitalWrite (LED_blue, HIGH);
73 delay (250);
74 digitalWrite (LED_red, HIGH);
75 digitalWrite (LED_blue, LOW);
76 delay (250);
77 digitalWrite (LED_red, LOW);
78 digitalWrite (LED_blue, HIGH);
79 delay (250);
80 digitalWrite (LED_red, HIGH);
81 digitalWrite (LED_blue, LOW);
82 delay (250);
83 digitalWrite (LED_red, LOW);
84 digitalWrite (LED_blue, HIGH);
85 delay (250);
86
87 }
88
89 if (digitalRead(tiltPin) == LOW) {
90 digitalWrite(LED_red, LOW);
91 digitalWrite(LED_blue, LOW);
92 digitalWrite(buzzerPin, LOW);
93 }
94}