Files
flash-led/flash_led.py
2026-03-26 19:03:19 +01:00

20 lines
394 B
Python

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.")