Mar-30-2018, 08:39 AM
I am working on opening a door with my Pi3, I have borrowed a lot of this code so far,as to I am very new to programming. I have this much working, now i want a text message when door opens and closes. I have installed Twilio and with the simple code
I can receive text message "Hello from Python" my problem is when i try to put this in the coding I have I get errors. Not really sure how and where to insert the code. I hope I am making sense. I have tried copy and pasting the import
all get is syntax errors or unexpected indent errors.
from twilio.rest import Client client = Client("ACxxxxxxxxxxxxxx", "zzzzzzzzzzzzz") client.messages.create(to="+19732644152", from_="+12023351278", body="Hello from Python!")
I can receive text message "Hello from Python" my problem is when i try to put this in the coding I have I get errors. Not really sure how and where to insert the code. I hope I am making sense. I have tried copy and pasting the import
from twilio.rest import Clientat the top with the rest of the imports. Then the rest under
if GPIO.input(11) == False: print ("Day") print ("Open door") GPIO.output(15,True) print ("drive motor") print ("Current time %s" % now )
all get is syntax errors or unexpected indent errors.
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(7,GPIO.IN) #LDR (Light Dependent Resistor) #GPIO.setup(11,GPIO.IN) #Top Switch #GPIO.setup(12,GPIO.IN) # Bottom Switch GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #top switch GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # bottom switch GPIO.setup(15,GPIO.OUT) # Door Open GPIO.setup(13,GPIO.OUT) # Door Close delay1 = 1 # time between checks when door moving for switch operation may need to be shorter delay2 = 5 # time between checks of LDR while True: while GPIO.input(7) == False: if GPIO.input(11) == False: print ("Day") print ("Open door") GPIO.output(15,True) print ("drive motor") print ("Current time %s" % now ) elif GPIO.input(11) == True: GPIO.output(15,False) print ("STOP door open") time.sleep(delay1) time.sleep(delay2) while GPIO.input(7) == True: if GPIO.input(12) == False: print ("Night") print ("Close door") GPIO.output(13,True) print ("drive motor") elif GPIO.input(12) == True: GPIO.output(13,False) print ("STOP door closed") time.sleep(delay1) time.sleep(delay2)Thanks Dualxeon