Physical Gmail Notification v2 - Solved

See Answer in Post 7

   if (val == 110) // n = 110 in dec

Instead of having to look values up in an ASCII table, change your code:

   if (val == 'n')

I Could output S to Ledpin 8 and P to Ledpin 9, this way creating different Leds to light up for different subjects.

What do you suppose pin 8 is going to do with an 'S'? Or pin 9 with a 'P'? What would either pin do is the value wasn't 'S' or 'P'?

I've updated the code on my pi, just not on the pc so val == 'n' - but thanks!

Different coloured LED's for different subjects.

n = 0 mails (all led's off)
m= Emails not matching subjects (Blue Led)
s = Sms emails from phone (i've got a forwarder set on android phone)
p = Missed Call Email (same forwarder as before)

s & p will have specific subjects so should be scrapable (is that a word) using the ["title"] in feedparser.

Sending any single letter, and turning on an LED seems like something you already know how to do, so I'm not sure what the issue is. Perhaps you could add a switch, and turn pins 8 and 9 off, if they are on, when the switch is pressed, as a reset for those pins.

Its inside the globe, and i'm after the globe being different colours for different events. I think its more of a python question, but also how to send the single letters for 4 different events really

off on subject 1 subject 2

Sorry if im not making the question clear.

but also how to send the single letters for 4 different events really

Just like you send for 2 different events, except that the letters are different.

I think its more of a python question,

I think so, too, and I can't help you there. I don't really care for snakes.

Thanks for trying.

as requested

This will notify you of any new gmails - also you can be notified of 2 different subject types, i'm using this to find SMS & phone - which are forwarded from my android phone

First part is the python gmail script.

#!/usr/bin/env python
import urllib
import feedparser
import serial
import sys

_url = "https://mail.google.com/gmail/feed/atom"

##################   Edit here      #######################

pwd = 'xxxxxxxx'                            # Put password
_username = 'xxxxxxxx'                 # Put email address
_maxmails = 5  # maximum new mails to show
SERIALPORT = "/dev/ttyACM0" # Change this to your serial port!
# Set up serial port
try:
	ser = serial.Serial(SERIALPORT, 9600)
except serial.SerialException:
	print "no device connected - exiting"
	sys.exit()

###########################################################

class GmailRSSOpener(urllib.FancyURLopener):
    '''Logs on with stored password and username
       Password is stored in a hidden file in the home folder'''

    def prompt_user_passwd(self, host, realm):
        #uncomment line below if password directly entered in script.
        return (_username, pwd)

def auth():
    '''The method to do HTTPBasicAuthentication'''
    opener = GmailRSSOpener()
    f = opener.open(_url)
    feed = f.read()
    return feed

def showmail(feed):
    '''Parse the Atom feed and print a summary'''
    atom = feedparser.parse(feed)
    newmails = len(atom.entries)
    if newmails == 0:
	ser.write("n")
        title = "0"
    elif newmails == 1:
	ser.write("m")
        title = "1"
    else:
	ser.write("m")
        title = "M"

    # print the title with formatting
    print title

    #then print the messages
    for i in range(min(_maxmails,newmails)):

        emailtitle = atom.entries[i].title
        if "SMS" in emailtitle:                # Change this to the subject you want to be notified for
		ser.write("S") 
		print "S"
	if "phone" in emailtitle:             # Change this to the subject you want to be notified for
		ser.write("P")
		print "P"

if __name__ == "__main__":
    feed = auth()
    showmail(feed)
# Close serial port
ser.close()

Sketch

// led wired + to pin 13, resistor to positive +5v

int outPin = 13; // Output connected to digital pin 13
int outPin2 = 8; // Output connected to digital pin 13
int outPin3 = 9; // Output connected to digital pin 13
int mail = LOW; // Is there new mail?
int SMS = LOW; // Is there new mail?
int PH = LOW; // Is there new mail?
int val; // Value read from the serial port
const int ledPin =  13;      // the number of the LED pin
const int ledPin2 =  8;      // the number of the LED pin
const int ledPin3 =  9;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000; 
void setup()
{
 pinMode(outPin, OUTPUT); // sets the digital pin as output
 pinMode(outPin2, OUTPUT); // sets the digital pin as output
 pinMode(outPin3, OUTPUT); // sets the digital pin as output
 Serial.begin(9600);
 Serial.flush();
 mail = LOW; // start off with lights out
 }

void loop()
{
    unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = LOW;
    else
      ledState = HIGH;
    // set the LED with the ledState of the variable:
    digitalWrite(outPin, ledState);
    digitalWrite(outPin3, ledState);
    digitalWrite(outPin2, ledState);}
 // Read from serial port
 if (Serial.available())
 {
   val = Serial.read();
   Serial.println(val, byte(0));

   if (val == 'n')
   {
     mail = LOW;
     SMS = LOW;
     PH = LOW;
   }

   if (val == 'm')
   {
     mail = HIGH;
   }   
   if (val == 'S') 
   {
     SMS = HIGH;
     mail = LOW; 
   }
      if (val == 'P') 
   {
     PH = HIGH;
     mail = LOW;
   }
   }
   
 // Set the status of the output pin
 digitalWrite(outPin, mail);
 digitalWrite(outPin2, SMS);
 digitalWrite(outPin3, PH);
}

Google give away free google voice account at North American;-
google voice support free Unlimited SMS inbound and outbound to any North American number, u do not need phone and arduino to send out SMS. at least at North American. U could send directly via google voice.