forked from futureshocked/RaspberryPiFullStack_Raspbian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blinky.py
56 lines (40 loc) · 1.01 KB
/
blinky.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'''
FILE NAME
blinky.py
1. WHAT IT DOES
Makes an LED blink using a Raspberry Pi.
2. REQUIRES
* Any Raspberry Pi
* A 5mm LED
* A 1KOhm resistor
* Jumper wires
3. ORIGINAL WORK
Raspberry Full stack 2018, Peter Dalmaris
4. HARDWARE
D07: LED
5. SOFTWARE
Command line terminal
Simple text editor
Libraries:
import RPi.GPIO as GPIO
import time (for 'sleep')
6. WARNING!
None
7. CREATED
8. TYPICAL OUTPUT
LED blinks
// 9. COMMENTS
--
// 10. END
'''
import RPi.GPIO as GPIO ## Import GPIO Library
import time ## Import 'time' library (for 'sleep')
pin = 7 ## We're working with pin 7
GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering
GPIO.setup(pin, GPIO.OUT) ## Set pin 7 to OUTPUT
for i in range (0, 20): ## Repeat 20 times
GPIO.output(pin, GPIO.HIGH) ## Turn on GPIO pin (HIGH)
time.sleep(1) ## Wait 1 second
GPIO.output(pin, GPIO.LOW) ## Turn off GPIO pin (LOW)
time.sleep(1) ## Wait 1 second
GPIO.cleanup()