import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

# Change 17 into the pin that is being used for the button
buttonPin = 15

GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Initialise a previous input variable to 0 (assume button not pressed last)
prev_input = 1
while True:
  # Read input
  input = GPIO.input(buttonPin)

  # If the last reading was low and this one high, print
  if ((not prev_input) and input):
    print("Button pressed")
  
  # Update previous input
  prev_input = input
  # Slight pause to debounce
  time.sleep(0.05)



