Barnes and Noble Maker’s Faire- Raspberry Pi Power, Activate!
This Saturday I’ll be part of a nationwide event being put on by the Raspberry Pi Organization and Barnes and Noble book stores. Makers Faire’s have been gaining international attention as the place to see really cool tech and inventions “in the wild” by everyday people making a difference.
Barnes and Noble Maker’s Faire Event
I’ll be presenting at my local Westminster, CO store and am really looking forward to the event. I was approached by Matt Richardson from the Raspberry Pi organization to participate and I was really honored to be picked to be part of this. The event was even advertised in the NY Times, so pretty cool stuff!
I’ll be talking about why we’ve chosen Raspberry Pi’s to introduce technical education to kids and adults for RMOUG’s Raspberry Pi and STEAM special interest group, the coaching volunteer work I’ve been lucky to be part of with Oracle Education Foundation and my recent partnerships with Devoxx4Kids, which is just a great organization over all for introducing kids to technology.
Now lets get into the Raspberry Pi projects I’ll be demonstrating at the event. Physical computing is very interactive, which means that its not just about the code, but really helps kids understand how much you can control with code. The interaction keeps them engaged and with a few projects, they really start to embrace it.
The Maker’s Faire Triad
I have two Raspberry Pi’s that I’ll be demoing- one has three projects connected via GPIO, (General Purpose Input/Output) with jumper wires. Two of the projects demonstrate how easy it is to purchase inexpensive models from a toy store and to hack them so that they can be controlled through code. The third project is just a motor, set up inside some Legos with a magnet and a plastic alien that can be positioned and spin in a dancing motion.
The take away from this project is to understand that the same code and a motor can do three very different things-
- Launch a paper airplane
- Make a robot walk
- Spin a character to music
Here’s the actual code:
import pibrella from subprocess import Popen import time proc = Popen(['mplayer', '-slave', '-playlist', 'http://ramfm.org/ram.pls']) #stream music as subprocess def dance_e(): pibrella.output.e.on() time.sleep(10) #run for 10 secs to match music pibrella.output.e.off() def plane_h(): pibrella.output.h.on() time.sleep(5) #plane runs best at 5 seconds pibrella.output.h.off() def robot_f(): pibrella.output.f.on() time.sleep(3) #robot walking for 3 seconds is good pibrella.output.f.off() plane_h() robot_f() dance_e() #run motor alien last, give music time to buffer time.sleep(10) proc.terminate() #kill subprocess and exit
The code is simple and clean, doing what needs to be performed:
Start some music and while that is buffering and running in the background, launch the airplane, run the robot and then make the alien dance, which will start just after the music starts, too.
RPI Oracle Bear Project
This is a project that I built out of an existing project I found online and then did some enhancements for Oracle Open World. I found myself at the conference without a co-presenter who had to go in for emergency surgery, so I wanted to do something with a Raspberry Pi and unfortunately, was out of time and our first idea was hardware challenged due to time constraints. I bought the bear in the conference retail center and began to work on him, introducing a Raspberry Pi to his innards and a camera in place of one of his eyes.
I set up app authorization to tweet via app.twitter.com and then built out the code from there with the additions I wanted for hashtags. I’ve now updated the tweets and hashtags to reflect the upcoming Maker Faire event, but here is the way the code works.
You click the button in his paw, the camera takes a picture, the code pulls from an array of tweets and hashtags, then it pushes it all and posts to Twitter-
The script calls an authorization file that grants it privileges to tweet as the RPI Oracle Bear user on Twitter. I installed the Twython module to use the code already built into the Raspberry Pi and configured my phone’s hotspot to ensure wifi access. I prefer my phone as it shows when the RPI is connected, verifying that I have wifi access, as there isn’t a monitor to display this information when the bear is active, (same with mouse, keyboard, etc. The code is running in the rc.local in the OS background, so no execution is necessary. It’s always on.)
from twython import Twython from picamera import PiCamera from time import sleep from datetime import datetime import RPi.GPIO as GPIO import random from auth import ( #authorization info for Twitter consumer_key, consumer_secret, access_token, access_token_secret ) GPIO.setmode(GPIO.BCM) GPIO.setup(14, GPIO.IN, GPIO.PUD_UP) twitter = Twython( #push auth codes to Twython consumer_key, consumer_secret, access_token, access_token_secret ) messages = [ #Tweets "Did you know over 7 million Rasperry Pi's have sold since 2012? ", "Nice to see you here! ", "You should follow @RpiOraclebear! ", "Do You Raspberry Pi? ", "Are you powered by a Raspberry Pi, too? ", "The Maker Faire at @BNBuzz ROCKS! ", "You can learn more about RPI at https://www.raspberrypi.org/magpi/! ", "A Raspberry Pi is only $35, you should get one! :) ", ] handles = [ #This is where you add hashtags to use "#RaspberryPi", "#BNMakerFaire", ] def main(): message = random.choice(messages) handle = random.choice(handles) with PiCamera() as camera: while True: GPIO.wait_for_edge(14, GPIO.FALLING) timestamp = datetime.now().isoformat() photo_path = '/home/pi/tweeting-rpibear/photos/%s.jpg' % timestamp sleep(3) camera.capture(photo_path) with open(photo_path, 'rb') as photo: twitter.update_status_with_media(status=[message handle], media=photo) #tweet will be a combo of one tweet and hashtag from list if __name__ == '__main__': main() camera.close()
This code is again very simple and clean. It’s not about making anything too complicated, just do the job that you want done. I’m considering moving the hashtags and tweet messages out to a separate files so if someone wanted to share the bear, (send it to conferences, people have asked…) that they could be given simple instructions to update the files and not the code, which would lessen mistakes.
I’ve added some velcro, secured the camera better into the eye socket with needle and thread, put all the batting in plastic bags to keep it out of the electronics and added a better button that “clicks” to know when the trigger has been engaged for the code.
Noel Portugal had a battery that worked really well with the RPI, so I’m going to hunt that down today, as I prefer the bear to be cordless, even for power. It just makes him all the more cooler to know he has a computer in him and like Pinocchio, no strings attached… 🙂
So I need to finish up my slides for this event, but I wanted to get the code out there and let folks know just what this event and the projects were all about. Don’t miss out, as I said, this is a nationwide event for Barnes and Noble, so look up your local store and be part of it!