Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import RPi.GPIO as GPIO
  4. import time, smtplib
  5.  
  6. GPIO.setmode(GPIO.BOARD)
  7. GPIO.setup(23, GPIO.IN)
  8. GPIO.input(23)
  9. red_pin = 18
  10. GPIO.setup(red_pin, GPIO.OUT)
  11. smtpserver = 'smtp.gmail.com:587'
  12. fromaddr = 'maurizioraspberry@gmail.com'
  13. toaddr = '197421maurizio@gmail.com'
  14. msg = 'mail1-7'
  15. #Aggiungo i dati per l'invio
  16. username = 'xxxxxxxxxx' #inserire proprio indirizzo
  17. password = 'xxxxxxxxxx' #inserire propria password
  18.  
  19. inviata = False
  20. while True:
  21. GPIO.output (red_pin, True)#led acceso
  22. time.sleep (0.5)
  23. GPIO.output (red_pin, False)#led spento
  24. time.sleep (0.5)
  25. time.sleep(1)
  26. if not GPIO.input(23):
  27. if not inviata:
  28. server = smtplib.SMTP(smtpserver)
  29. server.starttls()
  30. server.login(username, password)
  31. server.sendmail(fromaddr, toaddr, msg)
  32. server.quit()
  33. inviata = True
  34. else:
  35. inviata = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement