File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ #define PIN_LED 15
2+ #define PIN_BUTTON 13
3+
4+ bool buttonLatch;
5+ bool poweredOn;
6+
7+ void setup () {
8+ // put your setup code here, to run once:
9+ pinMode (PIN_LED, OUTPUT);
10+ pinMode (PIN_BUTTON, INPUT);
11+ }
12+
13+ void loop () {
14+ if (buttonLatch) {
15+ if (digitalRead (PIN_BUTTON) == LOW) {
16+ buttonLatch = false ;
17+ }
18+ return ;
19+ }
20+ if (digitalRead (PIN_BUTTON) == HIGH) {
21+ buttonLatch = true ;
22+ poweredOn = !poweredOn;
23+ if (poweredOn) {
24+ digitalWrite (PIN_LED, HIGH);
25+ } else {
26+ digitalWrite (PIN_LED, LOW);
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ <h2>🖼️ Projects</h2>
114114 < div class ="link-item highlight ">
115115 < a href ="button_latch.ino " target ="_blank "> Button Latch</ a >
116116 </ div >
117+ < div class ="link-item highlight ">
118+ < a href ="level_lamp.ino " target ="_blank "> Level Lamp</ a >
119+ </ div >
117120 < div class ="link-item ">
118121 < a href ="breakout.sb3 " target ="_blank "> Scratch Breakout</ a >
119122 < div class ="description "> The breakout game made during camp</ div >
You can’t perform that action at this time.
0 commit comments