Hardware Reference
In-Depth Information
# project
emailphoto(msgtext, latestphoto)
print “Report has been sent.”
#main program
def main():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16, GPIO.IN) #RF Remote Receiver
GPIO.setup(13, GPIO.IN) #Door switch
GPIO.setup(15, GPIO.IN) #Motion sensor
rfkey = False
while True:
if GPIO.input(16) == False: #RF key-fob key pressed
if rfkey == False:
rfkey = True
sendreport()
else:
rfkey = False
time.sleep(.3)
if __name__ == “__main__”:
main()
Over to You
Over the course of this chapter, you learned how to interface with sensors that give you informa-
tion about your home (movement, temperature, video and pictures). You acted on this informa-
tion by creating e-mail alerts, and in the last project I introduced an element of remote control.
You now have the building blocks for your next home automation project. Here are some ideas:
Place a door switch on a dog lap and send an e-mail every time your dog enters or
leaves the house.
Detect when your garage door has been open for more than 10 minutes.
Switch of a light when no motion is detected for a period of time.
hese projects, plus many more, are now well within your reach.
Search WWH ::




Custom Search