-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSE331ProjectV2.ino
94 lines (59 loc) · 2.52 KB
/
CSE331ProjectV2.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
87
88
89
90
91
92
93
94
#define LED_PIN0 8
#define BUTTON_PIN0 2
#define LED_PIN1 9
#define BUTTON_PIN1 3
#define LED_PIN2 10
#define BUTTON_PIN2 4
#define LED_PIN3 11
#define BUTTON_PIN3 5
void setup() {
pinMode(LED_PIN0, OUTPUT);
pinMode(BUTTON_PIN0, INPUT);
pinMode(LED_PIN1, OUTPUT);
pinMode(BUTTON_PIN1, INPUT);
pinMode(LED_PIN2, OUTPUT);
pinMode(BUTTON_PIN2, INPUT);
pinMode(LED_PIN3, OUTPUT);
pinMode(BUTTON_PIN3, INPUT);
}
void loop() {
// Condition for Output 0
if ((((!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1))) || ((!digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN0)))
|| ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN1)) && (digitalRead(BUTTON_PIN0))))
== HIGH) {
digitalWrite(LED_PIN0, HIGH);
} else {
digitalWrite(LED_PIN0, LOW);
}
// Condition for Output 1
if ((((digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)) && (digitalRead(BUTTON_PIN0)))
|| ((!digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)) && (!digitalRead(BUTTON_PIN0)))
|| ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)))
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)))
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN0)))
|| ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN0))))
== HIGH) {
digitalWrite(LED_PIN1, HIGH);
} else {
digitalWrite(LED_PIN1, LOW);
}
// Condition for Output 2
if ((((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)))
|| ((digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)))
|| ((!digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN0)))
|| ((!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)) && (!digitalRead(BUTTON_PIN0))))
== HIGH) {
digitalWrite(LED_PIN2, HIGH);
} else {
digitalWrite(LED_PIN2, LOW);
}
// Condition for Output 3
if ((((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2))) || ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN1)))
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)))
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN1)) && (!digitalRead(BUTTON_PIN0))))
== HIGH) {
digitalWrite(LED_PIN3, HIGH);
} else {
digitalWrite(LED_PIN3, LOW);
}
}