Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Beaglebone Python Programming

You're reading from   Learning Beaglebone Python Programming Unleash the potential of BeagleBone using Python

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781784399702
Length 196 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alexander C Hiam Alexander C Hiam
Author Profile Icon Alexander C Hiam
Alexander C Hiam
Arrow right icon
View More author details
Toc

LED displays

One of the simplest forms of hardware output that we can add to a program is an LED attached to a GPIO pin. We've already blinked LEDs, but not in a way that conveyed any sort of meaningful information; so first things first, we'll need something to communicate to the user. Here's a simple program that uses Internet Message Access Protocol (IMAP) to login to your email account and retrieve the number of unread messages in your inbox. Save it as a new file called email_counter.py, either in Cloud9 or your editor of choice over SSH, filling in the IMAP details for your account, as shown in the following code:

import imaplib

IMAP_host = "imap.gmail.com"
IMAP_email = "username@gmail.com"
IMAP_pass = "password"

email = imaplib.IMAP4_SSL(IMAP_host)

def connect():
    email.login(IMAP_email, IMAP_pass)

def disconnect():
    email.close()
    email.logout()

def get_num_emails():
    email.select("INBOX")
    ret, data = email...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image