Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Libraries import + variables declaration + some settings
- import processing.serial.*;
- import cc.arduino.*;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import java.util.Iterator;
- import java.util.List;
- import com.sun.syndication.feed.synd.SyndEntryImpl;
- import com.sun.syndication.feed.synd.SyndFeed;
- import com.sun.syndication.io.SyndFeedInput;
- import com.sun.syndication.io.XmlReader;
- int _count = 0;
- int timer;
- void setup() {
- size(470, 200);
- frameRate(1);
- timer = 0;
- background(255);
- arduino = new Arduino(this, "COM5", 57600);
- arduino.pinMode(13, Arduino.OUTPUT);
- }
- //Parser:
- Arduino arduino;
- void draw() {
- timer = second() % 30;
- if (timer == 0) {
- try {
- URL feedUrl = new URL("https://gmail.google.com/gmail/feed/atom");
- HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
- String encoding = new sun.misc.BASE64Encoder().encode("youraccounthere:yourpasswordhere".getBytes());
- httpcon.setRequestProperty ("Authorization", "Basic " + encoding);
- SyndFeedInput input = new SyndFeedInput();
- SyndFeed feed = input.build(new XmlReader(httpcon));
- List entries = feed.getEntries();
- System.out.println("Total Entries : " + entries.size());
- _count = entries.size();
- Iterator it = entries.iterator();
- }
- catch (Exception ex) {
- ex.printStackTrace();
- System.out.println("ERROR: " + ex.getMessage());
- }
- }
- if (_count > 0) {
- arduino.analogWrite (9, 180);
- }
- else {
- arduino.analogWrite (9, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement