Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import RPi.GPIO as GPIO
- import time, smtplib
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(23, GPIO.IN)
- GPIO.input(23)
- red_pin = 18
- GPIO.setup(red_pin, GPIO.OUT)
- smtpserver = 'smtp.gmail.com:587'
- fromaddr = 'maurizioraspberry@gmail.com'
- toaddr = '197421maurizio@gmail.com'
- msg = 'mail1-7'
- #Aggiungo i dati per l'invio
- username = 'xxxxxxxxxx' #inserire proprio indirizzo
- password = 'xxxxxxxxxx' #inserire propria password
- inviata = False
- while True:
- GPIO.output (red_pin, True)#led acceso
- time.sleep (0.5)
- GPIO.output (red_pin, False)#led spento
- time.sleep (0.5)
- time.sleep(1)
- if not GPIO.input(23):
- if not inviata:
- server = smtplib.SMTP(smtpserver)
- server.starttls()
- server.login(username, password)
- server.sendmail(fromaddr, toaddr, msg)
- server.quit()
- inviata = True
- else:
- inviata = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement