Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################################
- # As published in www.internetdelascosas.cl
- # Feel free to use and modify
- # PIR is connected as follows
- # Vdd P9.4
- # Gnd P9.1
- # Out P9.15
- # ref : http://www.gigamegablog.com/2012/03/16/beaglebone-coding-101-buttons-and-pwm/
- ############################################
- import os
- from time import sleep
- os.system("echo 48 > /sys/class/gpio/export")
- while(True):
- f = open("/sys/class/gpio/gpio48/value","r") # reading P9.15
- datos = f.read()
- vect = datos.split('\x00')
- switch = int(vect[0]) # convert to int type
- if switch == 0:
- print( "Not sensing presence")
- sleep(1)
- else:
- print ( "Sensing presence")
- sleep(1)
- f.close
- # To disable pin use
- # os.system("echo 48 > /sys/class/gpio/unexport")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement