Turn On a LED everytime I get a new mail from gmail

edited December 2013 in Arduino

I'm using this so I can turn on a led everytime I get a new mail from gmail but is not working can anyone help or has an idea?

import cc.arduino.*;
import processing.serial.*;

String url;
String lastItem;

Arduino arduino;
int ledPin = 13;



// ************************************************************************************************************************************************************************

void setup() {

 url = "https://mail.google.com/mail/feed/atom";

  arduino = new Arduino(this, Arduino.list()[0], 57600);
  arduino.pinMode(ledPin, Arduino.OUTPUT);
}

void draw() {

    XMLElement xml = new XMLElement(this, url);

    XMLElement[] titleXMLElements = xml.getChildren("channel/item/title");
    String recentItem = titleXMLElements[0].getContent();
    if(lastItem == null){
      lastItem = recentItem;
    }

    if (!lastItem.equals(recentItem)) {
      println("New item: " + recentItem);

      lastItem = recentItem;

      arduino.digitalWrite(ledPin, Arduino.HIGH);
      delay(100);
      arduino.digitalWrite(ledPin, Arduino.LOW);
    }

    delay(10000);
};

Answers

Sign In or Register to comment.