-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblink.py
More file actions
30 lines (24 loc) · 690 Bytes
/
blink.py
File metadata and controls
30 lines (24 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Reference: https://www.raspinews.com/blinking-led-on-raspberry-pi-using-python/
# Edited by: ArashMath
import RPi.GPIO as GPIO
import time
LedPin = 11
def setup():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LedPin, GPIO.OUT)
GPIO.output(LedPin, GPIO.HIGH)
def blink():
while True:
GPIO.output(LedPin, GPIO.HIGH)
time.sleep(0.5) #The number in this parentheses, shows the time LED is ON (in seconds)
GPIO.output(LedPin, GPIO.LOW)
time.sleep(0.5) #The number in this parentheses, shows the time LED is OFF (in seconds)
def destroy():
GPIO.output(LedPin, GPIO.LOW)
GPIO.cleanup()
if __name__ == '__main__':
setup()
try:
blink()
except KeyboardInterrupt:
destroy()