import RPIO import time # supress warning RPIO.setwarnings(False) # Which RPIO Numbering you like to use RPIO.setmode(RPIO.BCM) # OUT - Enable Port for the module enable_port=27 RPIO.setup(enable_port,RPIO.OUT) RPIO.gpio_function(enable_port) RPIO.output(enable_port,RPIO.LOW) #IN - Read the data data_port=17 RPIO.setup(data_port,RPIO.IN) #endless loop run=True read_count=0 while run : #Read data if (RPIO.input(data_port)): print "Port 17 => {0:5} :: HIGH :: Count {1} ".format(str(RPIO.input(data_port)), read_count) else: print "Port 17 => {0:5} :: LOW :: Count {1} ".format(str(RPIO.input(data_port)), read_count) read_count+=1 #wait 10ms time.sleep(0.1) #stop after 100 trys if (read_count > 100): run=False # Clean up RPIO.cleanup()