Hardware Reference
In-Depth Information
Engage thrusters
1. Using Python IDLE, let's get started with wriing a python script to achieve this task.
We will get started by imporing the feedparser module:
import sys
import feedparser
2. We will deine the funcion required to check e-mails:
newEmail=""
username="username@gmail.com"
password="password"
proto="https://"
server="mail.google.com"
path="/gmail/feed/atom"
def mail():
email = int(feedparser.parse(proto+username+":"+password+"@"+ser
ver+path)["feed"]["fullcount"])
return email
The preceding function has been borrowed from the WonderHo wTo
website ( http://null-byte.wonderhowto.com/how-to/
make-gmail-notifier-py thon-0132845/ ).
Let's save this function in a separate file and try to call it from another file.
For example, the function has been saved in a file called parser.py .
We will import parser.py in another file as a module and implement the
e-mail notifier. In this file, we will blink the LED when there is a new e-mail.
We will start by importing the parser module and RPi.GPIO :
import parser
import time
import RPi.GPIO as gpio
We will get started by setting the output pins for the e-mail notifier
example:
gpio.setwarnings(False)
gpio.setmode(gpio.BCM)
gpio.setup(17,gpio.OUT)
We will check for new e-mails and blink an LED if necessary:
while True:
mail = parser.mail() #check for email
 
Search WWH ::




Custom Search