Skip to content

Commit 8ff04d7

Browse files
Add files via upload
1 parent 6795d79 commit 8ff04d7

4 files changed

+199
-0
lines changed

Arduino-Uno-Pin-Diagram.png

134 KB
Loading

CSE331ProjectV2.ino

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#define LED_PIN0 8
2+
#define BUTTON_PIN0 2
3+
4+
#define LED_PIN1 9
5+
#define BUTTON_PIN1 3
6+
7+
#define LED_PIN2 10
8+
#define BUTTON_PIN2 4
9+
10+
#define LED_PIN3 11
11+
#define BUTTON_PIN3 5
12+
13+
void setup() {
14+
pinMode(LED_PIN0, OUTPUT);
15+
pinMode(BUTTON_PIN0, INPUT);
16+
17+
pinMode(LED_PIN1, OUTPUT);
18+
pinMode(BUTTON_PIN1, INPUT);
19+
20+
21+
pinMode(LED_PIN2, OUTPUT);
22+
pinMode(BUTTON_PIN2, INPUT);
23+
24+
pinMode(LED_PIN3, OUTPUT);
25+
pinMode(BUTTON_PIN3, INPUT);
26+
}
27+
void loop() {
28+
29+
// Condition for Output 0
30+
31+
if ((((!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1))) || ((!digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN0)))
32+
|| ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN1)) && (digitalRead(BUTTON_PIN0))))
33+
== HIGH) {
34+
35+
digitalWrite(LED_PIN0, HIGH);
36+
} else {
37+
digitalWrite(LED_PIN0, LOW);
38+
}
39+
40+
41+
42+
43+
44+
// Condition for Output 1
45+
46+
47+
if ((((digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)) && (digitalRead(BUTTON_PIN0)))
48+
|| ((!digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)) && (!digitalRead(BUTTON_PIN0)))
49+
|| ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)))
50+
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)))
51+
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN0)))
52+
|| ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN0))))
53+
== HIGH) {
54+
55+
digitalWrite(LED_PIN1, HIGH);
56+
} else {
57+
digitalWrite(LED_PIN1, LOW);
58+
}
59+
60+
61+
62+
63+
64+
// Condition for Output 2
65+
66+
67+
if ((((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)))
68+
|| ((digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)))
69+
|| ((!digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN0)))
70+
|| ((!digitalRead(BUTTON_PIN2)) && (!digitalRead(BUTTON_PIN1)) && (!digitalRead(BUTTON_PIN0))))
71+
== HIGH) {
72+
digitalWrite(LED_PIN2, HIGH);
73+
} else {
74+
digitalWrite(LED_PIN2, LOW);
75+
}
76+
77+
78+
79+
80+
81+
82+
83+
// Condition for Output 3
84+
85+
86+
if ((((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN2))) || ((digitalRead(BUTTON_PIN3)) && (!digitalRead(BUTTON_PIN1)))
87+
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN2)) && (digitalRead(BUTTON_PIN1)))
88+
|| ((!digitalRead(BUTTON_PIN3)) && (digitalRead(BUTTON_PIN1)) && (!digitalRead(BUTTON_PIN0))))
89+
== HIGH) {
90+
digitalWrite(LED_PIN3, HIGH);
91+
} else {
92+
digitalWrite(LED_PIN3, LOW);
93+
}
94+
}

CSE331ProjectV2ResisterFinal.ino

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
2+
3+
void setup() {
4+
5+
6+
DDRD = DDRD | 0B00000000;
7+
DDRB = DDRB | 0B001111;
8+
}
9+
void loop() {
10+
11+
// Condition for Output 0
12+
13+
14+
15+
if ((((!(PIND & 0B00010000)) && (!(PIND & 0B00001000))) || ((!(PIND & 0B00100000)) && (!(PIND & 0B00010000)) && (!(PIND & 0B00000100)))
16+
|| ((PIND & 0B00100000) && (!(PIND & 0B00001000)) && (PIND & 0B00000100)))
17+
== HIGH) {
18+
19+
20+
PORTB = PORTB | 0B000001;
21+
22+
23+
24+
25+
} else {
26+
27+
28+
29+
PORTB = PORTB & 0B111110;
30+
}
31+
32+
33+
34+
35+
36+
// Condition for Output 1
37+
38+
39+
40+
if ((((PIND & 0B00010000) && (!(PIND & 0B00001000)) && (PIND & 0B00000100)) || ((!(PIND & 0B00010000)) && (PIND & 0B00001000) && (!(PIND & 0B00000100)))
41+
42+
|| ((PIND & 0B00100000) && (!(PIND & 0B00010000)) && (PIND & 0B00001000))
43+
44+
|| ((!(PIND & 0B00100000)) && (PIND & 0B00010000) && (!(PIND & 0B00001000)))
45+
46+
|| ((!(PIND & 0B00100000)) && (PIND & 0B00010000) && (PIND & 0B00000100)) || ((PIND & 0B00100000) && (!(PIND & 0B00010000)) && (!(PIND & 0B00000100))))
47+
48+
== HIGH) {
49+
50+
PORTB = PORTB | 0B000010;
51+
52+
53+
} else {
54+
55+
PORTB = PORTB & 0B111101;
56+
}
57+
58+
59+
60+
61+
62+
// Condition for Output 2
63+
64+
65+
66+
67+
if ((((!(PIND & 0B00100000)) && (PIND & 0B00010000) && (PIND & 0B00001000))
68+
69+
|| ((PIND & 0B00100000) && (PIND & 0B00010000) && (!(PIND & 0B00001000)))
70+
|| ((!(PIND & 0B00100000)) && (!(PIND & 0B00010000)) && (PIND & 0B00000100))
71+
|| ((!(PIND & 0B00010000)) && (!(PIND & 0B00001000)) && (!(PIND & 0B00000100))))
72+
== HIGH) {
73+
74+
PORTB = PORTB | 0B000100;
75+
76+
} else {
77+
78+
PORTB = PORTB & 0B111011;
79+
}
80+
81+
82+
83+
84+
85+
86+
87+
// Condition for Output 3
88+
89+
90+
91+
92+
93+
if ((((PIND & 0B00100000) && (!(PIND & 0B00010000))) || ((PIND & 0B00100000) && (!(PIND & 0B00001000)))
94+
|| ((!(PIND & 0B00100000)) && (PIND & 0B00010000) && (PIND & 0B00001000))
95+
|| ((!(PIND & 0B00100000)) && (PIND & 0B00001000) && (!(PIND & 0B00000100))))
96+
== HIGH) {
97+
98+
99+
100+
PORTB = PORTB | 0B001000;
101+
} else {
102+
103+
PORTB = PORTB & 0B110111;
104+
}
105+
}

Setup.png

141 KB
Loading

0 commit comments

Comments
 (0)