got an LED to blink on GPIO18
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
# From https://raspberry.tips/en/raspberrypi-tutorials/raspberry-pi-gpio-python
|
||||
import lgpio
|
||||
import time
|
||||
|
||||
# Open GPIO chip (0 = /dev/gpiochip0, on Pi 5 gpiochip4 also possible)
|
||||
h = lgpio.gpiochip_open(0)
|
||||
|
||||
try:
|
||||
lgpio.gpio_claim_output(h, 18) # GPIO18 (pin 12) as output (MOTA1)
|
||||
|
||||
for _ in range(5):
|
||||
lgpio.gpio_write(h, 18, 1) # HIGH
|
||||
time.sleep(0.5)
|
||||
lgpio.gpio_write(h, 18, 0) # LOW
|
||||
time.sleep(0.5)
|
||||
|
||||
finally:
|
||||
lgpio.gpiochip_close(h) # Always close!
|
||||
Reference in New Issue
Block a user