forked from eyering/picamera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestGPIO.py
More file actions
40 lines (30 loc) · 721 Bytes
/
testGPIO.py
File metadata and controls
40 lines (30 loc) · 721 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
31
32
33
34
35
36
37
38
import RPi.GPIO as GPIO
import time
import camera
print("sys.version : ")
print(sys.version + "\n")
print("GPIO.VERSION : " + GPIO.VERSION)
print("GPIO.RPI_INFO['P1_REVISION'] = " + str(GPIO.RPI_INFO['P1_REVISION']))
io20 = 20
io21 = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(io20,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(io21,GPIO.OUT)
print("PRess button to turn ON LED");
try:
while(True):
if(GPIO.input(io20)):
GPIO.output(io21,GPIO.LOW)
else:
GPIO.output(io21,GPIO.HIGH)
camera.capture()
except KeyboardInterrupt:
print("\n")
print("Exit by KeyboardInterrupt\n")
except:
print("\n")
print("Exit by Other case!\n")
finally:
GPIO.cleanup(io20)
GPIO.cleanup(io21)
print("Clean up GPIO\n")