Skip to content

Instantly share code, notes, and snippets.

@a-r-d
Created June 3, 2012 18:41
Show Gist options
  • Save a-r-d/2864555 to your computer and use it in GitHub Desktop.
Save a-r-d/2864555 to your computer and use it in GitHub Desktop.
Push email to arduino-> to LED ASCII display

what

goal

  • Change this so that we actually send message contents to the board and display on an led scroll panel in text form.
  • Also show the number of emails.
  • Do something else that is cool.
int outPin = 12; // Output connected to digital pin 12
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port
void setup()
{
pinMode(outPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
Serial.flush();
}
void loop()
{
// Read from serial port
if (Serial.available())
{
val = Serial.read();
Serial.println(val);
if (val == 'M') mail = HIGH;
else if (val == 'N') mail = LOW;
}
// Set the status of the output pin
digitalWrite(outPin, mail);
}
#!/usr/bin/env python
import serial, sys, feedparser, time
def getMail():
#Settings - Change these to match your account details
USERNAME="[email protected]"
PASSWORD="yourpassword"
PROTO="https://"
SERVER="mail.google.com"
PATH="/gmail/feed/atom"
SERIALPORT = "/dev/tty.usbserial-FTDK0P3M" # Change this to your serial port!
# Set up serial port
try:
ser = serial.Serial(SERIALPORT, 9600)
except serial.SerialException:
sys.exit()
newmails = int(feedparser.parse(
PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH
)["feed"]["fullcount"])
# Output data to serial port
if newmails > 0: ser.write('M')
else: ser.write('N')
# Close serial port
ser.close()
def main():
while(1):
getMail()
time.sleep(60)
return 0
if __name__ == '__main__':
main()
@sauditrevor
Copy link

when i run this code on pythone idle , it brings an error SyntaxError: multiple statements found while compiling a single statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment