Ho controllato la sintassi e non mi da errori ma appena faccio partire il programma ottengo questo:
Code: Select all
Traceback (most recent call last):
File "mail1-b7blink.py", line 10, in <module>
GPIO.output(18)
TypeError: function takes exactly 2 arguments (1 given)Cmq questo è il programma:
Code: Select all
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time, smtplib
GPIO.setmode(GPIO.BOARD)
GPIO.setup(23, GPIO.IN)
GPIO.setup(18, GPIO.OUT)
GPIO.input(23)
GPIO.output(18)
GPIO.output(18, True)
GPIO.output(18, False)
GPIO.setwarnings(False)
smtpserver = 'smtp.gmail.com:587'
fromaddr = 'xxxx'
toaddr = 'xxxx'
msg = 'mail1-7'
#Aggiungo i dati per l'invio
username = 'xxxxxxxxx' #inserire proprio indirizzo
password = 'xxxxxxxxx' #inserire propria password
inviata = False
stato = True
while True:
GPIO.output(18, stato)
stato = not stato
time.sleep(0.5)
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