def cleanup(): """ Function to cleanup raspberry pi GPIO at end of code """ # Restore GPIO to default state GPIO.remove_event_detect(15) #Add to end of function GPIO.cleanup() print("GPIO cleaned!")