forked from cymplecy/scratch_gpio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sgh_InputTest.py
executable file
·55 lines (41 loc) · 1.63 KB
/
sgh_InputTest.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
#!/usr/bin/env python
# sgh_GPIOController - control Raspberry Pi GPIO ports using RPi.GPIO by Ben Crosten
# and servod by Richard Hirst
#Copyright (C) 2013 by Simon Walters
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Version = '0.1.0' # 12Nov13
import RPi.GPIO as GPIO
import time
import os
import datetime as dt
import threading
def getPiRevision():
"Gets the version number of the Raspberry Pi board"
return GPIO.RPI_REVISION
def cleanup(self):
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.cleanup()
GPIO.setup(11, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(12, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(13, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
#while GPIO.input(11) == GPIO.HIGH:
# time.sleep(0.01) # wait 10 ms to give CPU chance to do other things
while 1:
print
print GPIO.input(11)
print GPIO.input(12)
print GPIO.input(13)
time.sleep(0.2) # wait 10 ms to give CPU chance to do other things
print "finished"