Building hardware is exciting because you get to interact with the “real world”. In this project you will use the LightBlue Bean to receive notifications from Facebook and Twitter (and any other sources!) and pop up a notification flag using a servo. It’s a fun, physical indicator for your Twitter mentions or Facebook messages! Best of all, you clear the notification by just putting the flag back down, just like an old-fashioned mailbox.
The LightBlue Bean is a fun little Arduino compatible platform that you interact with over Bluetooth Low Energy. It’s like a normal Arduino, but you’ll never have to plug it in–you program it wirelessly. The Bean is what we’ll use to receive the notifications and move the servo.
First we have to make a couple modifications to our Bean to add a battery pack and servo connector. All the parts are available in the Maker Kit.
Solder the battery pack on the pins labeled BAT and GND. The Red wire goes to BAT and black to GND. This will provide the additional power needed to move the servo.
Solder the servo connector to the proto-board on the Bean. Note the pinout; the yellow wire from the servo cable is the signal pin. It should go to the pin labeled "0" on the Bean (digital IO zero). The red wire from the servo is power, connect it to VCC on the Bean. The black wire on the servo cable is ground, connect it to GND on the Bean.
We will use Python (an easy scripting language) to pull email notifications using the gmail module, check if the sender is Facebook or Twitter, and then send them using the pyserial module.
If you haven't already, download the code, available on github. and install the gmail and pyserial modules. This is easily done by running pip install requirements.txt in the root directory of the repo.
I recommend creating a new Gmail account to receive notifications. This prevents you from needing to store your password credentials to your main account in your Python code.
Set up Facebook and Twitter to send email notifications to your new email address. If you like, you can forward them back to your main account as well.
Run the Python code in terminal by browsing to the directory and typing python Bean_Notification.py
You may have to do a bit of calibration to get your Flag to sit straight up after a notification. If you send an email to your account with the subject "test", the flag will go to it's upright position. If that doesn't suit your set up, you can pop off the servo arm, and remount it any angle you wish. Alternatively, you can edit FACEBOOK_SERVO_NOTIFY_POSITION in the Arduino sketch to whatever value you want.
Alright, you're all set! Go post this project on your Facebook page, or Tweet it, and wait for the comments to roll in. When you get a notification email, your Flag will pop up. When you want to clear the notification, just push the flag back down.
We'll assume you're ok with this, but you can opt-out if you wish.