Standalone LED flash script

This commit is contained in:
2026-03-26 19:03:19 +01:00
commit 38e093a403
2 changed files with 26 additions and 0 deletions

7
README.md Normal file
View File

@@ -0,0 +1,7 @@
# Flash-LED
Standalone Python script to flash an LED on GPIO 17 of a Raspberry Pi.
## Usage
`python3 flash_led.py`
Requires `RPi.GPIO` to be installed on the host.

19
flash_led.py Normal file
View File

@@ -0,0 +1,19 @@
import RPi.GPIO as GPIO
import time
# Use GPIO 17
PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.OUT)
try:
print("Flashing LED for 10 seconds...")
start_time = time.time()
while time.time() - start_time < 5:
GPIO.output(PIN, GPIO.HIGH)
time.sleep(0.3)
GPIO.output(PIN, GPIO.LOW)
time.sleep(0.3)
finally:
GPIO.cleanup()
print("Done.")