Wednesday, April 18, 2012

Road Trip to America's Dairyland - NCPH/OAH 2012

Laura, Adriana, and I have arrived safely in Milwaukee, Wisconsin for the National Council on Public History & Organization of American Historians 2012 Annual Conference.  We had a very enjoyable road trip and even arrived early enough to do a little exploring in Milwaukee.  Since it is late, and my volunteer shift is early tomorrow, I'll tell the story of our day in pictures.  (You can also check my Twitter for a play-by-play...)

Ready to go!

Doughnuts Adriana was talking about

Rest stop in Indiana

Chicago for lunch

Walking around Milwaukee

With the "Bronze Fonz"

Market

Outside convention center

Monday, April 16, 2012

The Wonderboy - "Sweet Spot"

There is a part of the baseball bat called the "sweet spot."  It's that magical place on the bat, where a "combination of factors (physics and all that) results in a maximum response for a given amount of effort."  When you swing a bat and it connects with the baseball at the sweet spot, you hear a clear crack, the bat doesn't vibrate, and the ball soars beautifully through the air.  It's an awesome feeling, like everything has come together at the right moment.

I have found the "sweet spot" of my interactive exhibit design project.  It has taken all semester, in which I spent innumerable hours Google searching Arduino code and brought me nearly to tears of frustration at times.  But after taking all of the hardware and the working code I described in my last post about the Wonderboy and loading it onto my batting helmet, I am finally there.  I'm amazed at how closely my finished project resembles the original idea of a "history appliance" I had at the beginning of the semester.  The final product is definitely a home run, if I do say so myself!

I made a brief video demonstrating how all the hardware attached to the batting helmet for the finished product:  


I've admitted several times that these courses - digital history/interactive exhibit design - have taken me further outside my academic comfort zone than I've ever been before.  It made me recognize one of the biggest lessons that grad school has taught me - don't be afraid to try new things, stretch yourself, step outside your comfort zone.  I'm still amazed at the technical things I accomplished this semester with no background in programming at all.  If you would have told me last year I'd be doing all this, I'm not sure I would have believed you.  It just goes to show that you should never stop trying new things, or pigeon-hole yourself.

My classmate Dave summed up our lessons very well, when he talked about "The Nine Letters, or Three Laws, of the Digital Historian" - do-it-yourself (DIY), steal from others (SFO), and share with others (SWO).  I certainly tried to do all of those things this semester.  Though perhaps I did more stealing than sharing, I'm hoping that perhaps my lessons, trials, and tribulations will be of assistance to someone, someday.

So it is with a bit of a heavy heart that I dismantle the Wonderboy, and return the guts of my project to my professor Bill.  It will be forever immortalized in pictures of my classmates willing to put it on and give it a try:

Douglas

Matt

Lindsay
 
Sushima

Finally, if you are interested, here is the Arduino code I used to program my final project:

int IRpin = 0;  // analog pin for reading the IR sensor
int val = 0;       // analog pin for reading the IR sensor

#include "WaveHC.h"
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time
SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
 Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  Serial.begin(9600);                             // start the serial port
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
   
  if (!card.init()) {         //play with 8 MHz spi (default faster!)
  putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
  sdErrorCheck();
  while(1);                            // then 'halt' - do nothing!
  }
   
  card.partialBlockRead(true);

  // Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                             // we found one, lets bail
  }
   if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }

  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?

  // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);                             // then 'halt' - do nothing!
  }
}

void loop() {
   val = analogRead(IRpin);
  Serial.println(val);                       // print the distance
 
  
if(val > 60 && val < 128){
  playcomplete("SCHMIDT.WAV");
  }
else{
  //do nothing
  }
  delay(50);

val = analogRead(IRpin);
  Serial.println(val);                       // print the distance

if(val > 129 && val < 196){
  playcomplete("VENTURA.WAV");
  }
else{
  //do nothing
  }
   delay(50);

val = analogRead(IRpin);
  Serial.println(val); 
  // print the distance

if(val > 197 && val < 264){
  playcomplete("BONDS.WAV");
  }
else{
  //do nothing
  }
 delay(50);
   
val = analogRead(IRpin);
  Serial.println(val);                       // print the distance
   
if(val > 265 && val < 332){
  playcomplete("CURTIS.WAV");
  }
else{
  //do nothing
   }
  delay(50);

val = analogRead(IRpin);
  Serial.println(val);                       // print the distance
   
if(val > 333 && val < 400){
  playcomplete("CARTER.WAV");
  }
else{
  //do nothing
  }
  delay(50);
}


// Plays a full file from beginning to end with no pause.
 void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}
void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
   
  // ok time to play! start playback
  wave.play();
}

Road Trip Plans!

It's only two days and counting until Adriana, Laura, and I hit the road and head to the National Council on Public History/Organization of American Historians 2012 Conference!  Things are a flurry of activity in the public history room of requirement as the semester comes to an end, and we all rush to finish papers and projects so as not to have them hanging over our heads during the conference.

We've already mapped out our drive, including meal breaks (breakfast at Cracker Barrel after we cross the border, lunch at the original Pizzeria UNO in downtown Chicago.)  We also hope to spend a couple hours walking around downtown Chicago - we even found a free app for walking tours.

We also have some plans for sightseeing in Milwaukee.  Adriana found a statue of the Fonz that we're going to check out.  Laura heard about a unique spy restaurant, for an evening when we feel like a night on the town. When we have some down time, I'd like to head over to the Historic Third Ward district and check out the Milwaukee Public Market.

I have a feeling that it is going to be a busy five days, as these are just the things we would like to do outside of the actual conference.  There is plenty in the conference program to keep us busy.  As I mentioned in my last post about our plans, I will be attending the speed networking session, new members breakfast, women in history luncheon, and serving as a volunteer at registration on the first day of the conference.  I've been looking over the sessions trying to decide what to attend, and there are so many choices!  There are times when it would be nice if I could be in three places at once!

I am looking forward to meeting new people (and seeing old friends - one of my fellow 2009 interns from the Baseball Hall of Fame is going to be there!)  I received notice of my mentoring match and will be meeting up with Mary Rizzo of the New Jersey Council for the Humanities on Thursday evening.  I'll also have a chance to mingle with fellow grad students on the Riverwest Bus Tour - which I'll be reviewing for The Public Historian.

Stay tuned for more road trip and conference updates! 


"Aaaaay, it'll be a great trip!"

Tuesday, April 3, 2012

The Wonderboy - Rounding the Bases, Heading for Home

April is here, which means the semester is coming to an end.  In baseball terms, we're done with the regular season and we're heading into the post-season (a bit of a confusing analogy when you consider that opening day is this week - but you get my drift...)  This is when it really counts, this is when you have to get it done...

In my last post about the Wonderboy, I discussed some of the problems I ran into trying to write the sketch (code) for the Arduino and wave shield I am using for my project.  I managed to find the solution for the SPI.h error message I was recieving on the AF_Wave library code, but even though the error message was gone, the wave shield still wasn't playing my audio files.  Then this message appeared on the wave sheild website last week:


That pretty much solved the WaveHC vs. AF_Wave debate, but posed yet another problem.  So far, all the sketch examples I had found online using an IR distance sensor as an input device also used the older AF_Wave library.

The IR (infrared) distance sensor was also a new piece of hardware I was still figuring out.  My professor Bill, had this one on hand for me to use.  Luckily there is a lot of information online about this product and using it with an Arduino, so I was able to find plenty sketches that use this IR sensor.  Then last week during class, as I was walking my classmate Sarah through my project, she showed me how to open the serial port and record the analog values coming from the sensor.  This was a huge step to figuring out how to get different audio files to play at different distances from the sensor.
These numbers represent different distances from the sensor.

If you are at all confused at this point - join the club.  By now, I have all of the hardware assembled that I need for the project - the Arduino (an open-source electronics prototyping platform), the Ladyada Wave Shield (shield that allows me to add the audio), and the Sony IR sensor (analog input device that will trigger the audio to play.)  Now all I needed was the sketch that would bring them all together.

I had yet to discover a sketch online that encompassed everything I was trying to do, and used the WaveHC library.  So I started to build by own sketch, and let me tell you it was difficult.  But it also forced me to go through the different sketches and figure out what each part did (which was good for me in the long run.)  As I was Googling error messages to try to figure out what was wrong with the sketch I was writing I came across a forum topic about the 'sdErrorCheck' message.

As I'm reading down the page, I discover that this guy is doing the exact same thing I want to do, and he is only one error message a way from figuring it out!  Luckily his question was answered, and I was able to adopt his code for my project.  I pretty much just had to insert my audio files and change the analog values for my distance sensor!

The sketch that worked!

And with that - the Wonderboy started working!


Stay tuned for a final wrap-up and a look at the project once the hardware it all on the batting helmet!