From 38e093a403c5151b55c6b7c5e21d342f22510cf9 Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 26 Mar 2026 19:03:19 +0100 Subject: [PATCH] Standalone LED flash script --- README.md | 7 +++++++ flash_led.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 README.md create mode 100644 flash_led.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..f840099 --- /dev/null +++ b/README.md @@ -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. diff --git a/flash_led.py b/flash_led.py new file mode 100644 index 0000000..f29156f --- /dev/null +++ b/flash_led.py @@ -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.")