-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_blinkingLed_1.py
31 lines (25 loc) · 968 Bytes
/
01_blinkingLed_1.py
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
#!/usr/bin/env python
#-----------------------------------------------------------
# File name : 01_blinkingLed_1.py
# Description : make an led blinking.
# Author : Jason
# Website : www.electrobot.co.in
# E-mail : [email protected]# Date : 2015/06/12
#-----------------------------------------------------------
import RPi.GPIO as GPIO
import time
LedPin = 11 # pin11
GPIO.setmode(GPIO.BOARD) # Numbers pins by physical location
GPIO.setup(LedPin, GPIO.OUT) # Set pin mode as output
GPIO.output(LedPin, GPIO.HIGH) # Set pin to high(+3.3V) to off the led
try:
while True:
print '...led on'
GPIO.output(LedPin, GPIO.LOW) # led on
time.sleep(1)
print 'led off...'
GPIO.output(LedPin, GPIO.HIGH) # led off
time.sleep(0.5)
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the flowing code will be executed.
GPIO.output(LedPin, GPIO.HIGH) # led off
GPIO.cleanup() # Release resource