Lights! Camera! Action!
This week, we will explore Internet Queries using the Intel® Edison and the Arduino breakout board.
Here is a video of the completed project.
Using a set of dials, set a decade and a movie genre. Pressing the button will activate the Movie Recommender and the search begins. After the magic is done, the curtain will open to reveal the movie that fits the criteria.
So get this project done, make some popcorn, dim the lights, and get ready to watch a sci-fi movie from 1988... “My Stepmother is an Alien”?!
Thanks to The Open Movie Database (OMDB) for providing the search API.
Here is a list of items you’ll need to make this project:
Intel® Edison with the Arduino breakout board
Edison power supply
4 mm MDF components - lasercut according to drawing
Fabric component - lasercut according to drawing
Decorative printout - printed in color
2 10k Ohm potentiometer
2 Knob covers
1 push button
1 standard servo
1 16*2 LCD screen
4 M8 bolts
Nuts and bolts
Assembling the Movie Recommender and electronics:
Sort the lasercut pieces for easier construction.
Solder the electronics.
Use the schematic to solder the electronic components together.
Optional: Attach decorative printout (Part C1) to Part A1 to using spray adhesive.
Make movie curtain.
Attach Part A11 and Part A12 along the long edges of Part D1.
Cut string (approx. 30 cm) and tie to Part A11.
Mount Intel® Edison to base and attach electronics.
Attach Intel® Edison to Part A10 using Parts B4 as spacers in between.
Attach Part A10 to Part A5.
Place the LCD into Part A5.
Insert Part A5 into Part A10.
Attach curtain, side panel, and dials/button.
Place the potentiometers and button through the slit on Part A10.
Attach Part A2 to Part A4.
Slide the curtain into the appropriate slots.
Attach Part A6 to assembly.
Attach the potentiometers and button to Part A1 and secure.
Place dial covers on potentiometer.
Attach front panel and weigh down and secure curtain.
Attach Part A1 to assembly.
Place two M8 bolts on each side of Part A12.
Place Part B2 into the slots on Part A11.
Attach servo and assemble wheel.
Insert the servo into Part A3 and secure from behind using Part B3.
Attach Part A3 to assembly.
Assemble and attach wheel.
Attach Part A7, Part A8, and Part A9 together in that order.
Insert the servo arm and secure.
Attach to the servo.
Attach string to curtain mechanism.
Pull the string through Part A3 and place Parts B1 into Part A2 to act as a guide for the string.
Turn the wheel counter clockwise as far as possible and then back a little.
Slide string through the slot and wrap around multiple times to secure.
Programming the Intel® Edison
Follow the getting started guide http://www.intel.com/support/maker/edison.htm#how.
Make sure you have the wifi connection working.
Scp the python script to the Intel® Edison.
Download “MovieRecommender.py” from the zip in attachment.
Find out the ip address of Intel® Edison. Type “ifconfig” in the serial terminal, you can see the ip in wifi network under section “wlan0”.
Open a terminal in your computer. Copy the python script over by typing “scp /path/to/MovieRecommender.py root@EdisonIP:/home/root/”
Upload the sketch.
The basic LCD screen is a simple and low tech way of adding a display to your project. Follow the example from http://arduino.cc/en/Tutorial/LiquidCrystal to connect the LCD to Intel® Edison.
In this project we’re using a 16 x 2 LCD with 16 pin input, which is the same as used in the Arduino tutorial so the steps are fairly similar.
The “system()” command.
When running Arduino sketches on the Intel® Edison, you can use the “system()” command to execute any Linux system commands. This makes it much easier for people familiar with Arduino to access advanced functionalities in the Linux system.
However the system() command only accepts char array as argument. In order to execute dynamically created commands, it would be much easier if the command string can be assembled dynamically, e.g., Char path=”~/myFolder”; String cmd=“ls “+path;
Using char array would be too rigid to be convenient. To convert String to char array, you can use the String.buffer property. So from the example above, just carry it out by calling system(cmd.buffer);
Behind the Scenes
The actual movie finding is handled by the python script. It is activated in Arduino sketch by calling the “system()” command.
Despite the dials labels, the OMDB API actually doesn’t allow search by genre or decade. So instead, a list of frequently appearing title words are used for keyword searching. Science fiction, for instance, may have “space”, “ufo”, “alien”, “laser”, “star”, etc.
Once set and the button is pushed, the Intel® Edison will send a randomized year within the decade and a random associated word - e.g. “1988” and “alien”. OMDB will then send back a list of movies from 1988 that contain “alien” in its title.
After the list is retrieved, the Intel® Edison uses the first movie and sends another request to OMDB for its genre. If it doesn’t match the science fiction genre, it will continue to send requests of the other movie titles until it finds one that does. If none are found, it will repeat the process using a different associated word until successful.