I am setting up my raspberry pi with a motion sensor. I am using some simple code python code from modmypie. I run the code from the terminal window, but getting SyntaxError: invalid syntax
on print (“Motion Detected!”). This is such a simple line, but can't figure out what the issue is.
# coding: utf-8
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
PIR_PIN = 7
GPIO.setup(PIR_PIN, GPIO.IN)
def MOTION(PIR_PIN):
print “Motion Detected!”
print “PIR Module Test (CTRL+C to exit)”
time.sleep(2)
print “Ready”
try:
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)
while 1:
time.sleep(100)
except KeyboardInterrupt:
print “ Quit”
GPIO.cleanup()
print (“Motion Detected!”), but your code saysprint “Motion Detected!”. Your question is tagged with Python 2.7, but my RP runs on Python 3... you may check this and switch the interpreter, if necessary.