Advertisement
Laszlo

Notificator

Jul 15th, 2012
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. //Libraries import + variables declaration + some settings
  2.  
  3. import processing.serial.*;
  4. import cc.arduino.*;
  5. import java.net.HttpURLConnection;
  6. import java.net.URL;
  7. import java.util.Iterator;
  8. import java.util.List;
  9.  
  10. import com.sun.syndication.feed.synd.SyndEntryImpl;
  11. import com.sun.syndication.feed.synd.SyndFeed;
  12. import com.sun.syndication.io.SyndFeedInput;
  13. import com.sun.syndication.io.XmlReader;
  14.  
  15. int _count = 0;
  16. int timer;
  17.  
  18. void setup() {
  19.   size(470, 200);
  20.   frameRate(1);
  21.   timer = 0;
  22.   background(255);
  23.   arduino = new Arduino(this, "COM5", 57600);
  24.   arduino.pinMode(13, Arduino.OUTPUT);
  25. }
  26.  
  27.  
  28. //Parser:
  29.  
  30. Arduino arduino;
  31.  
  32. void draw() {
  33.   timer = second() % 30;
  34.   if (timer == 0) {
  35.     try {
  36.       URL feedUrl = new URL("https://gmail.google.com/gmail/feed/atom");
  37.  
  38.       HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
  39.       String encoding = new sun.misc.BASE64Encoder().encode("youraccounthere:yourpasswordhere".getBytes());
  40.       httpcon.setRequestProperty ("Authorization", "Basic " + encoding);
  41.       SyndFeedInput input = new SyndFeedInput();
  42.       SyndFeed feed = input.build(new XmlReader(httpcon));
  43.  
  44.       List entries = feed.getEntries();
  45.       System.out.println("Total Entries : " + entries.size());
  46.       _count = entries.size();
  47.       Iterator it = entries.iterator();
  48.      
  49.     }
  50.     catch (Exception ex) {
  51.       ex.printStackTrace();
  52.       System.out.println("ERROR: " + ex.getMessage());
  53.     }
  54.   }
  55.  
  56.   if (_count > 0) {
  57.     arduino.analogWrite (9, 180);
  58.   }
  59.   else {
  60.     arduino.analogWrite (9, 0);
  61.   }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement