From 09394fb2ecda35e013e4b5d6e0539cd9bb2a0b13 Mon Sep 17 00:00:00 2001 From: tilman Date: Sun, 18 Dec 2016 09:01:22 +0100 Subject: [PATCH] buttons.py --- code/test/buttons.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 code/test/buttons.py diff --git a/code/test/buttons.py b/code/test/buttons.py new file mode 100644 index 0000000..bdff3b2 --- /dev/null +++ b/code/test/buttons.py @@ -0,0 +1,29 @@ +import RPi.GPIO as GPIO +import time + +GPIO.setmode(GPIO.BCM) + +# Buttons on PINs 9, 10 and 11 +GPIO.setup(9, GPIO.IN, pull_up_down=GPIO.PUD_UP) +GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_UP) +GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +try: + print('Start button test') + + while True: + if (GPIO.input(9) == False): + print('Button 1') + + if (GPIO.input(10) == False): + print('Button 2') + + if (GPIO.input(11) == False): + print('Button 3') + + time.sleep(0.25) + +except KeyboardInterrupt: + print('bye') + GPIO.cleanup() +