santa detector not working in python - Raspberry Pi Forums


i want create motion detector .i tried in scratch -in scratch create brodcast programme , not seeing gpio4 option in sensor block. try in python using command this
*************************************************************
import rpi.gpio gpio
import time

sensor = 4

gpio.setmode(gpio.bcm)
gpio.setup(sensor, gpio.in, gpio.pud_down)

previous_state = false
current_state = false

while true:
time.sleep(0.1)
previous_state = current_state
current_state = gpio.input(sensor)
if current_state != previous_state:
new_state = "high" if current_state else "low"
print("gpio pin %s %s" % (sensor, new_state))

***********************************************************
run programme . python showing this

>>>

traceback (most recent call last):
file "/home/pi/hi.py", line 7, in <module>
gpio.setup(sensor, gpio.in, gpio.pud_down)
runtimeerror: no access /dev/mem. try running root!
>>>

did do. 1 please

the message

code: select all

runtimeerror: no access /dev/mem. try running root!
means have run script

code: select all

sudo python hi.py
accessing gpio needs root permission.


raspberrypi



Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code