You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
540 B
Python
20 lines
540 B
Python
# button setup (connect to GND and board Pin 21)
|
|
import RPi.GPIO as GPIO # GPIO pins
|
|
#import time
|
|
|
|
|
|
def print_button():
|
|
|
|
GPIO.setmode(GPIO.BOARD) #Use the physical board number (not GPIO numbering)
|
|
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Change pin if necessary #print button
|
|
GPIO.setwarnings(False) #Ignore warnings
|
|
|
|
print_button_pressed = False
|
|
|
|
if GPIO.input(21) == GPIO.LOW:
|
|
#time.sleep(1)
|
|
print_button_pressed = True
|
|
GPIO.cleanup() #GPIO clean up
|
|
|
|
return print_button_pressed
|