-
-
Save dbrova15/f18899e1eb47eb3672b2f009e9eb94ed to your computer and use it in GitHub Desktop.
GPIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
from time import sleep | |
import os | |
from display import show_text | |
foo_top = None | |
foo_middle = None | |
foo_down = None | |
# def buttons(foo_top, foo_middle, foo_down): | |
def buttons(): | |
#GPIO.cleanup() | |
#GPIO.setmode(GPIO.BCM) | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setwarnings(False) # Turn off warnings output | |
GPIO.setup(32, GPIO.OUT) # Set pin #38 (GPIO12) to output | |
GPIO.setup(29, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin #40 (GPIO05) to input | |
GPIO.setup(31, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin #40 (GPIO06) to input | |
GPIO.setup(33, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin #40 (GPIO13) to input | |
# show_text("Welcome!") | |
while True: | |
button_top = bool(GPIO.input(29)) | |
button_middle = bool(GPIO.input(31)) | |
button_down = bool(GPIO.input(33)) | |
print(button_top, button_middle, button_down) | |
if button_top is True: | |
print('Top') | |
GPIO.cleanup() | |
# foo_top | |
# break | |
elif button_middle is True: | |
print('Middle') | |
GPIO.cleanup() | |
# foo_middle | |
elif button_down is True: | |
print('Down') | |
GPIO.cleanup() | |
# foo_down | |
else: | |
pass | |
sleep(1) | |
if __name__ == "__main__": | |
# foo_top = show_text(["foo_top!"]) | |
# foo_middle = show_text(["foo_middle!"]) | |
# foo_down = show_text(["foo_down!"]) | |
buttons() | |
# buttons(show_text(["foo_top!"]), show_text(["foo_middle!"]), show_text(["foo_down!"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment