Friday, April 27, 2012

Arduino Based Book Report Diorama



     My 10yr old daughter recently had to do a diorama for a school book report as a presentation. Seeing examples of diorama's from museums, libraries and other kids projects at school she asked if we could make it cool. Asking her what she meant by "make it cool" she asked if we could add lights or moving parts to it, in which I was more then glad to accommodate as it would be a great way to introduce her to micro controllers and earn her another badge for the Adafruit "Hack Scouts".

In wanting her to learn just what micro controllers are used for I lent her my copy of "Getting Stared with Arduino" which even though is a little technical for younger readers just getting started, was a great reference tool to show her just a few examples of what people can do with an Arduino and explain the coding involved within Arduino.


Her design (as seen below) called for some simple things that were easy to accomplish with the Arduino platform. She wanted to have a yellow glowing light shining from inside the dresser drawer as described in the book, a light on the ceiling in the boys room, the boy, a bed, and a dresser.


Originally when helping her plan things out she wanted to have the dresser drawer open & close but unfortunately due to time & cost restraints we had to skip that moving part of the diorama and leave it fully open with just the LED's lighting up.

Taking a trip to our local Radio Shack we picked up a Servo motor, a 10mm white LED, & 2 yellow 3mm LED's for less then $20. Starting work on her project on April 22nd Earth Day I thought it would also be good to incorporate the use of recycled materials from parts & wire we already had here at the house from our parts pile which usually consists of broken computers, printers, scanners, etc.

To prevent any trips to the hospital I cut and shaped out the wooden box for the diorama along with the dresser, & bed. She picked the colors she wanted to paint things and we got to work on the projects appearance. Next we positioned everything were it needed to be along with hot gluing down things like the dresser, bed & LED's in their respective locations.








 After all the eye candy was done we went to work on the back of the box where the wires and everything else would be housed at. Already working towards earning her multimetter skill badge we talked about the importance of wiring and why Ohms law was so important when dealing with electronics, though while she didn't grasp all parts of Ohm's law she knows with out the use of a resistor in certain parts of electronic you might damage the micro controller.






When it came time to make the Ardunio work it's magic we used the "Sweep" example by BARRAGAN found within the Arudino example library and modified it to match our specifications as well as add the function to turn on the LED's.
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>

Servo myservo;   // create servo object to control a servo
                            // a maximum of eight servo objects can be created

int pos = 0;          // variable to store the servo position

void setup()
{
 pinMode(13, OUTPUT);    
  pinMode(12, OUTPUT);

  myservo.attach(7);  // attaches the servo on pin 7 to the servo object
}


void loop() {
 digitalWrite(13, HIGH);   // turn on the LED
  digitalWrite(12, HIGH);   //turn on the LED
 
  for(pos = 0; pos < 40; pos += 1)    // goes from 0 degrees to 40 degrees
  {                                                     // in steps of 1 degree
    myservo.write(pos);                     // tell servo to go to position in variable 'pos'
    delay(15);                                     // waits 15ms for the servo to reach the position
  }
  for(pos = 40; pos>=1; pos-=1)       // goes from 40 degrees to 0 degrees
  {                               
    myservo.write(pos);                     // tell servo to go to position in variable 'pos'
    delay(15);                                     // waits 15ms for the servo to reach the position
  }
}
The video below is my 10yr old daughter showing off her project and giving a "shout out" to the open source hardware community.




While we won't know her final grade until next week, she has told me after the comments from YouTube, Twitter & seeing her project appear on the Adafruit blog , she knows it's an A+.

On a side note a very big THANK YOU to everyone who has left comments on her project. A very big thank you to the Arduino community & to Adafruit for their idea of "Hack Scouts" and everyone else doing work with the Open Source Hardware Community.