Skip to content

Commit 494e7d2

Browse files
committed
feat: add test_up.py for controlling UP_PIN with GPIO
1 parent 7da9ac3 commit 494e7d2

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

scripts/test_up.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# test_up.py
2+
import time
3+
import RPi.GPIO as GPIO
4+
5+
UP_PIN = 17 # BCM numbering, physical pin 11
6+
7+
GPIO.setmode(GPIO.BCM)
8+
9+
def release_up():
10+
# High-impedance: "button not pressed"
11+
GPIO.setup(UP_PIN, GPIO.IN, pull_up_down=GPIO.PUD_OFF)
12+
13+
def press_up():
14+
# Drive low: "button pressed"
15+
GPIO.setup(UP_PIN, GPIO.OUT, initial=GPIO.LOW)
16+
17+
try:
18+
# Make sure we're released at start
19+
release_up()
20+
print("Ready. Desk should NOT move yet.")
21+
22+
input("Press Enter to move UP for 2 seconds...")
23+
24+
print("Moving UP...")
25+
press_up()
26+
time.sleep(2.0) # adjust if you want a shorter/longer test
27+
release_up()
28+
print("Released UP. Test finished.")
29+
30+
finally:
31+
# Ensure we leave the line released
32+
release_up()
33+
GPIO.cleanup()

0 commit comments

Comments
 (0)