I am building motion sensor camera,,, so whenever any motion will be detected it should send sms..
i have tried following code for that..
Code: Select all
import RPi.GPIO as GPIO
import time
import picamera
import datetime
from twilio.rest import TwilioRestClient
def get_file_name():
return datetime.datetime.now().strftime("%Y-%m-%d_%H.%M.%S.h264")
def sms():
ACCOUNT_SID = "my_Acc_Sid"
AUTH_TOKEN = "my_auth_token"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
message = client.messages.create(
body="Hello Motion Detected.... !", # Message body, if any
to="+91xxxxx",
from_="+121xxxxx",
)
print message.sid
return
sensor=7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)
previous_state=False
current_state=False
cam=picamera.PiCamera()
while True:
time.sleep(0.01)
previous_state=current_state
current_state=GPIO.input(sensor)
if current_state!=previous_state:
print "Values outside the function: ", sms()
new_state="HIGH" if current_state else "LOW"
print("GPIO pin %s is %s"%(sensor,new_state))
if current_state:
fileName=get_file_name()
cam.start_preview()
cam.start_recording(fileName)
else:
cam.stop_preview()
cam.stop_recording()
GPIO.cleanup()
File "t4.py", line 34
print "Values outside the function: ", sms()
^
IndentationError: expected an indented block
please solve this error for me...
