Standalone LED flash script
This commit is contained in:
19
flash_led.py
Normal file
19
flash_led.py
Normal 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.")
|
||||
Reference in New Issue
Block a user