Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie with Pi3
#1
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
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 Client
at 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
Reply


Messages In This Thread
Newbie with Pi3 - by Dualxeon - Mar-30-2018, 08:39 AM
RE: Newbie with Pi3 - by buran - Mar-30-2018, 09:32 AM
RE: Newbie with Pi3 - by Dualxeon - Mar-30-2018, 10:26 AM
RE: Newbie with Pi3 - by Dualxeon - Mar-30-2018, 10:19 PM
RE: Newbie with Pi3 - by snippsat - Mar-30-2018, 10:38 PM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 05:53 AM
RE: Newbie with Pi3 - by Dualxeon - Mar-31-2018, 08:28 AM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 08:48 AM
RE: Newbie with Pi3 - by Dualxeon - Mar-31-2018, 09:25 AM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 10:00 AM
RE: Newbie with Pi3 - by Dualxeon - Mar-31-2018, 10:28 AM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 10:47 AM
RE: Newbie with Pi3 - by Dualxeon - Mar-31-2018, 12:09 PM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 12:23 PM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 07:29 PM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 07:47 PM
RE: Newbie with Pi3 - by Dualxeon - Mar-31-2018, 08:55 PM
RE: Newbie with Pi3 - by buran - Mar-31-2018, 09:13 PM
RE: Newbie with Pi3 - by Dualxeon - Apr-01-2018, 08:51 AM
RE: Newbie with Pi3 - by wavic - Apr-01-2018, 09:07 AM
RE: Newbie with Pi3 - by buran - Apr-01-2018, 08:57 AM
RE: Newbie with Pi3 - by buran - Apr-01-2018, 09:13 AM
RE: Newbie with Pi3 - by wavic - Apr-03-2018, 09:47 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-01-2018, 09:14 AM
RE: Newbie with Pi3 - by buran - Apr-01-2018, 09:27 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-01-2018, 09:36 AM
RE: Newbie with Pi3 - by buran - Apr-01-2018, 09:40 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-01-2018, 11:34 AM
RE: Newbie with Pi3 - by buran - Apr-01-2018, 12:14 PM
RE: Newbie with Pi3 - by Dualxeon - Apr-01-2018, 06:32 PM
RE: Newbie with Pi3 - by buran - Apr-01-2018, 08:08 PM
RE: Newbie with Pi3 - by Dualxeon - Apr-02-2018, 10:19 AM
RE: Newbie with Pi3 - by buran - Apr-02-2018, 11:13 AM
RE: Newbie with Pi3 - by buran - Apr-02-2018, 11:20 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-03-2018, 07:33 AM
RE: Newbie with Pi3 - by buran - Apr-03-2018, 07:41 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-03-2018, 08:46 AM
RE: Newbie with Pi3 - by buran - Apr-03-2018, 08:56 AM
RE: Newbie with Pi3 - by buran - Apr-03-2018, 09:01 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-03-2018, 09:17 AM
RE: Newbie with Pi3 - by buran - Apr-03-2018, 10:14 AM
RE: Newbie with Pi3 - by buran - Apr-03-2018, 11:04 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-04-2018, 07:40 AM
RE: Newbie with Pi3 - by buran - Apr-04-2018, 08:02 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-04-2018, 08:30 AM
RE: Newbie with Pi3 - by buran - Apr-04-2018, 09:08 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-04-2018, 09:15 AM
RE: Newbie with Pi3 - by buran - Apr-04-2018, 09:22 AM
RE: Newbie with Pi3 - by Dualxeon - Apr-04-2018, 08:14 PM
RE: Newbie with Pi3 - by buran - Apr-04-2018, 08:21 PM
RE: Newbie with Pi3 - by Dualxeon - Apr-04-2018, 10:58 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020