Step #1: Customize your Bean
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.
Step #2: Fly your Facebook flag high
Cut out your flag from a sturdy material like foam core or cardboard.
Print out whatever icon you would like. Our graphics for the icons and dials used are available here. Or get creative and print or draw your own!
Glue the icon onto your card-stock or foam core base. You can either use rubber cement or superglue to glue the flag onto the servo arm that comes with your servo.
Step #4: Arduino Goodness
All of the code is available on github.
Open the Sketch and hit Build. If you have LightBlue Bean selected it will open the Bean Loader Application.
Connect to your Bean using the Loader App, and program the sketch.
We will use a virtual serial port to send the Facebook / Twitter notifications. Right Click on the Bean and select 'Use for Virtual Serial'.
Step #5: Get the Notifications Ready
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
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.
Like the Punch Through facebook page and trigger a flag in our office!
The Arduino sketch disables the servo after moving it into position, so you won't hear any annoying buzzing sounds.
Step #9: Go one step further!
Ready for more? We have some ideas on how to extend the project. Create a San Francisco summer weather indicator! We have one image listed to get you started. Icon credit.
Or, add another servo to track Facebook and Twitter notifications. You could track other things like sports scores, page visits, or earthquake activity!