Skip to content

Commit 24e7366

Browse files
committed
level lamp
1 parent 9158faf commit 24e7366

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

2025/level_lamp.ino

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

2025/links.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)