With the another drove of news that are critical of Android's security and recent OSX's security woes which experts blame on Apple's lack of transparency., I think the time is right to create this image.
Benjamin Franklin is one of my favorite heroes that I look up to. He was a statesman, scientist, inventor, musician and philosopher as well as one of the founding father of United States ,and hence father of the modern world.
So what would Benjamin Franklin have chosen if he was given a choice between Apple's iOS and Android?
I think answer is obvious. I don't think the close system will ever be as secure as open systems in the long run. Don't forget iOS is only 5 years old. So let's wait and see what would happen in the future.
P.S. I realize there are different version of this quote but this one is my favorite and cover the whole concept.
"Those who sacrifice liberty for security deserve neither and will lose both"- Benjamin Franklin.
[from the previous post] While I am taking a little break last week for mid sem break, I decided to do a physical Gmail notifier , as if all notifications from my gtalk , phone and tablet are not enough . Well , the catch is this will notify me only for the important messages . So I can turn off notifications from other gmail clients notifying me of unwanted mails. The design is simple ,using gmail's priority inbox feature)I fetch the important mail from gmail rss feed (https://mail.google.com/gmail/feed/atom/important) using python script and send data to arduino using pyserial .
What it does
The incoming important mail will raise the mail flag, display the mail title in LCD (scrolling) , light up notifier LED and play melody.
Watch a short demo video:
The followings are photos of mail in priority inbox or lack of that.
Pyserial is python module for serial communication. Feedparser is module for parsing the emails. Pyserial installation is easy since it is exe file (if you use windows). However, feedparser installation could be tricky if you are a newbie to python like me. You need to add python directory to Windows' "PATH" envionment variables. Then use the command prompt to install feedparser as mentioned in feedparser documentation page. (Hit me up in the comments for any problem).
Step 2: Get Connected
Connect hardware components as follows.
Step 3: Get codes.
Upload Arduino sketch file. You can change melody as you like. You can compose a new one all the notes are in pitches.h. Mine is a simple alarm melody that I like . simple piano score B,G,A,D, , D,A,B,G.
/* * This code reads serial port for email. * If mail is present, it will turn on LED, display on LCD and scroll the display, * raise flag and play defined melody
*copyleft by Aung Thiha *created in April 12 *last modified April 15 *This code is in public domain *www.engineeringthecure.blogspot.com */
#include <LiquidCrystal.h>
#include "pitches.h"
#include <Servo.h>
#define MAX 45 // servo maximum degree. I am making it turn counterclockwise so 0 degree to 45 degreee. It depends on your servo position and configuration
#define MIN 0 // servo minium degreeLiquidCrystal lcd(12,11,5,4,3,2);
int ledPin =13;
char ser;
String email ="";
int servoPin = 9;
// notes in the melody: you can write any melody you like// this is a tune I like. so I coverted the piano note int melody[] = {NOTE_B5,NOTE_G4,NOTE_A5,NOTE_D4,0,NOTE_D4,NOTE_A5,NOTE_B5,NOTE_G4,0};
// note durations: duration for a note to play. 4 = quarter note, 8 = eighth note, etc.:// Not important for this tune, but u need to change it if you want to run other other tunesint noteDurations[] = { 4,4,4,4,4,4,4,4,4,4};
Servo flag;
voidsetup(){
Serial.begin(9600);
lcd.begin(16,2);
pinMode(ledPin,OUTPUT);
flag.attach(servoPin);
}
voidloop(){
lcd.clear();
lcd.setCursor(0,0);
if (Serial.available()) {
lcd.print("connected");
lcd.setCursor(0,1);
ser = Serial.read(); //read the serial port//if incoming character is 0, no mail, LED is low if (ser == '0'){
digitalWrite(ledPin,LOW);
flag.write(MIN);
//lcd.write("You got no mail!");
}
//if other characters, servo flag turns, Lcd display and play sound"elseif(ser > '0') {
flag.write(MAX);
lcd.clear();
email += ser;
digitalWrite(ledPin,HIGH);
getEmail(); //parse email function ,code block is below
printEmail(); //print email ,code block is below
playSound(); // play melody
email =""; // reset email
}
}
delay(1000);
}
/* *parse the email from incoming characters. *adding each character to email string */void getEmail(){
while(Serial.available()>0){
char nextChar = Serial.read();
email += nextChar;
}
}
/* * print email and scroll it * */void printEmail(){
int emailLength = email.length();
lcd.setCursor(0,0);
lcd.print(email);
delay(500);
//scroll it to left until the final char of email is displayed on LCDfor (int positionCounter = 0; positionCounter <emailLength-12; positionCounter++) {
lcd.scrollDisplayLeft();
delay(500);
}
lcd.clear();
lcd.print(email);
}
/*This code play tune from melody array . * literally from public domain code* from arduino Tone tutorial http://arduino.cc/en/Tutorial/Tone*/void playSound(){
// iterate over the notes of the melody:for (int thisNote = 0; thisNote < 10; thisNote++) {
// to calculate the note duration, take one second // divided by the note type.//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.int noteDuration = 2000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.// the note's duration + 30% seems to work well:int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:noTone(8);
}
}
Then get python script. Open new Window >> paste codes >> saved it under any name with .py extension. Put in your email, password, change serial port that is same as port on arduino.I pointed the path to "important" label to get priority mails. You can change that to specific label just by pointing to your label instead of important. You can set your own filters and label as explained in the link.Reminder about python: index is very important in python. Copy exactly as follow.
import serial, sys, feedparser,time
#Settings - Change these to match your account details
USERNAME="youremail@gmail.com"
PASSWORD="yourpassword"
PROTO="https://"
SERVER="mail.google.com"
PATH="/gmail/feed/atom/important"
mySerial= serial.Serial('COM5',9600) #change port to your setting.
while True:
gmail = feedparser.parse(PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH)
unread = len(gmail.entries)
#"print ("Unread:{0}".format(unread)) #uncomment if you want it to dispaly on your desktop
if unread ==0:
mySerial.write(0)
time.sleep(10)
#print("no mail")
elif unread>0:
gmail_latest = gmail.entries[0]
title = gmail_latest.title
author = gmail_latest.author
#print (title)
#print (author)
mySerial.write("[{0}] {1} ".format(unread,title))
time.sleep(20)
mySerial.flushOutput()
Step 4. Test it
Run python script by using F5.
You can always disable some function to suit your need. e.g You might not want sound or display the message at certain time. Then you just need to disable that part of code on arduino. I wrote it in code block exactly to do just that. If something is wrong , check the connection.
Step 5. Put genie in the box :)
Create the box as creative as you can. I create a cube just because I love the cube design. (not because of Steve Jobs btw.)
Yahoo! You've no mail :)
You have got a mail :(
References. There are links that give me inspiration and some codes :)
These two philosophies have been integral part of my daily living long before I read this quote. I would prefer to eradicate sufferings all together and that is exactly what the title of my blog means. I am a strong believer in technology as our salvation and accordingly I am a follower of many technology trends. You can find the trends and tech news I follow on Engineering The Cure Facebook page.
My latest musing is about synthetic biology as I believe engineering a life form is the frontier of engineering. I could imagine all sort of advancement that synthetic biology could enable: from new food resources , geoengineering , energy production to healthcare.
P.S I found this picture on Google+. I don't know who is original creator. I tried to find by Google image search but it returns hundreds of links.
While I am taking a little break this week for mid sem break, I decided to do a physical Gmail notifier , (as if all notifications from my gtalk , phone and tablet are not enough :P). Well , the catch is it will notify only for the important messages (using gmail's priority inbox feature). So I can turn off notifications from other gmail clients as there are a lot of spams in my inbox(well, 99.99% spam is from my university. mails for all the events I don't give a damn ). The design is simple ,I fetch the important mail from gmail rss feed (https://mail.google.com/gmail/feed/atom/important) using python script and send data to arduino using pyserial . There is a notification LED and a lcd screen displaying title of latest important mail which obviously are controlled by Arduino. LED and LCD should be off if there is no new mail. To do list: put a speaker ;P, write tutorial on my blog, and integrate twitter notification. I will be doing them next week if I could find some time.. The main benefit is I learnt a couple of python tricks in this hack.;)