Found some arduino's and then, 6 red LED's. So, I figured I had to build something that counts using a six bit binary system.
Then I found This blog on how to make a physical gmail notifier, and really liked the idea, so I adapted the code, and fought with the plist file used (on macs, dunno how to do this on PC) to run the python script with a specified interval, and now it works!
So now, I have a little wooden block next to the mac, showing me how many unread e-mails I have.. which allows me to see if I have any, and if so, how many, from a distance. Can't do without that, obviously.
In case more people feel inspired, this is the code used on the arduino:
(mind you, I'm not a real good programmer, so it can probably be done easier, or better, but hey, this works for me)
int pinArray[] = {2, 3, 4, 5, 6, 7};
int nomailpin = 8;
int mail = LOW;
int val;
int outerloop;
int value;
int bit;
int innerloop;
int pinLoop;
int bitSetter;
int amount;
int mailcount;
int oldval;
int timer = 25;
int count = 0;
void setup()
{
Serial.begin(9600);
Serial.flush();
pinMode(nomailpin, OUTPUT);
for (pinLoop = 2; pinLoop < 7; pinLoop++)
{
pinMode(pinLoop, OUTPUT);
digitalWrite(pinLoop, LOW);
}
}
void loop()
{
if (Serial.available()) {
val = Serial.read();
Serial.println(val);
mailcount = val+1;
if (val != 0) {
if (val != oldval) {
change();
}
Serial.print("mail");
num_mails();
digitalWrite(nomailpin, LOW);
oldval = val;
}
else if (val == 0) {
for (pinLoop = 2; pinLoop < 7; pinLoop++) {
digitalWrite(pinLoop, LOW);
}
for (int j=0;j < 4;j++) {
digitalWrite(nomailpin, HIGH);
delay(100);
digitalWrite(nomailpin,LOW);
delay(100);
digitalWrite(nomailpin,HIGH);
delay(100);
digitalWrite(nomailpin,LOW);
delay(100);
}
digitalWrite(nomailpin, HIGH);
oldval = val;
}
}
}
void num_mails()
{
for (outerloop = 0; outerloop < mailcount; outerloop++){
bitSetter = outerloop;
for (innerloop = 2; innerloop < 10; innerloop++){
value = bitSetter / 2;
bit = bitSetter % 2;
if (bit == 1){ digitalWrite(innerloop, HIGH);}
if (bit == 0){ digitalWrite(innerloop, LOW);}
bitSetter = value;
}
}
}
void change()
{
for (int count=0;count<6;count++) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer);
}
for (count=5;count>=0;count--) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer);
}
}
This is the python code:import serial, sys, feedparser
#Settings
USERNAME="YourEmail@gmail.com"
PASSWORD="YOURPASSWORD"
PROTO="https://"
SERVER="mail.google.com"
PATH="/mail/feed/atom"
SERIALPORT = "/dev/tty.usbserial-A7006vlT"
# 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
ser.write(chr(int(newmails)))
# Close serial port
ser.close()
Of course, you will have to put your username and password in the script, and change this : dev/tty.usbserial-A7006vlT for the address of your arduino (you can find that in the arduino software under Tools > Serial port).
Then, you need to put a .plist file in your Launchagents folder (in your Lib) containing this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.j4mie.check-gmail</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>/Users/yourusername/path/to/check-gmail.py</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
Make sure to enter the correct path to both your python file, and your pyton interpreter.. it's often not just /usr/bin/python as in this file.. make sure you have the one you get when running python in your terminal.. that's the one you want to use..
So, when all this is done, you should be able to see the LED's (or whatever you build) show you your amount of unread mail every minute.. I made a little movie showing my finished notifier block:
Enjoy!

