#!/usr/bin/python3 import time import Adafruit_BBIO.GPIO as GPIO # Set up gpio 60 as input GPIO.setup("P9_12", GPIO.IN) # Sets an event when pin 60 changes to 1 GPIO.add_event_detect("P9_12", GPIO.RISING) i = 0 while True: time.sleep(1) if GPIO.event_detected("P9_12"): f = open('/tmp/sensor', 'w') f.write(str(int(time.time())) + '\n') f.close() i = i + 1 print(str(i) + " Event!!!")