Showing posts with label wonderboy. Show all posts
Showing posts with label wonderboy. Show all posts

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();
}

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!

Wednesday, March 21, 2012

The Wonderboy - Hits and Misses

In baseball, if you're batting .300, you're doing pretty well.  Keep in mind this means you are getting a hit only 3 out of every 10 times you step up to the plate.

This is something I've been reminding myself quite a bit as I work through developing my interactive exhibit.  It seems as if every time I solve one problem, two more seem to pop up!

In my last post about the Wonderboy, I talked about my plans to use an Adafruit wave shield hooked up to an Arduino to produce the sound that will be wired into the batting helmet.  My professor, Bill, brought a wave shield into class for me to work with.  I started working through the steps on the online tutorial, just with the hope of getting some sound out of the shield.  Instead, every time I tired to verify the sketch before uploading it to the Arduino, I got an error message.  At the time, I had just started working with sketches, codes, and processing language, so I was having a hard time figuring out what was wrong.  Bill suggested I Google the error message I was getting and see if others had had the same problem.  When class was over that day, and I was no closer to solving the error message, I had a conversation with Bill that went something like this:


He encouraged me to keep banging my head against the wall, and I'd figure it out (at the time I thought that was the stupidest advice I'd ever gotten - turns out he was right!)  I was so determined to figure it out, I took my Arduino home and kept working.  Finally, I found my error.  It turns out that when I downloaded the library to use with the wave shield, I had saved it in the wrong place on my computer.  Yes, you read that correctly, the mistake was that small.  (Fortunately, I wasn't the only one to ever make this mistake, as I found the solution to my problem in an online forum where someone else posted about getting the same error message.)

So as this point I had the Arduino recognizing the wave shield attached to it, but I didn't have sound yet.  Per the instructions of the tutorial, I was working with the waveHC library and was trying to get the dap_hc.pde sketch to play all of the home run audio files I had on a loop.  (This isn't my ultimate goal, but I wanted to start somewhere.)

I tried running the dap_hc.pde sketch, but again, I was getting an error message.  After Googling this error message, I was directed to the Arduino website.  Turns out there had been a update the the Arduino software, and so I had to make some changes to the code in the waveHC library I downloaded.


This was completely new territory for me.  I started opening the files that had come with the waveHC library, and making the code changes where I could.  The files looked something like this:

 

After going through and making all the additions/changes the error messages on the Arduino sketch finally went away and there was sound - YEA!


So since I had solved the problem with using the waveHC library.  I copied and pasted the sketch for the Halloween Pumpkin project (which is similar to what I plan to do with my project) into the Arduino and tried to verify it.  Guess what?  I got an error message!  It turns out that the pumpkin project uses the older AF_Wave library (which I had read was cumbersome to use) as opposed to the newer waveHC library that I had just finished fixing on my computer.

So it was back to another round of getting error messages:


And trying to figure out how to solve them:

  

At this point I still haven't solved my SPI.h error message.  So I'm debating between trying to work out the error and get the AF_Wave library working.  Or trying to figure out how to rewrite the pumpkin project code so it will work with the waveHC library that is operational for me at this point.  Either way, it involves a lot of writing and rewriting code, which is still very new for me.

Also, my professor Bill is currently soldering my wave shield so we can hook up a distance sensor as an input device.  I have a feeling that this will lead to a whole new group of error messages.

Hopefully, batting .300 will continue to be good enough for this project!

Friday, February 24, 2012

The Wonderboy - Deconstructed

Last week, in my Interactive Exhibit Design course, we had a chance to play with Google SketchUp.  Of all the programs we have used so far, I found this the easiest to learn.  Not only is the program user-friendly, but Google provides some excellent tutorials for beginners and advanced users.  I used my class time to go though a Museum Exhibit Mockup Prof. Turkel provided.  I was going to include the one I made in class on my blog, but after looking at what Lindsay had done with her Immigrant's Suitcase, I knew I had to step-up my game a bit.

Some of you may remember my original idea for a "history appliance" - Wonderboy, the interactive baseball bat.  I used SketchUp to visualize how this exhibit might be set up in a museum.

*Bonus point to anyone who can figure out which famous home run is depicted in the projected images.
If you recall from my original idea, this exhibit allows you to experience what it would be like to hit a record-breaking home run.  Speakers in the batters helmet provide audio of the announcers and the roar of the crowd, while the images from the projectors put you on the field.

Using what I have learned so far in the class, brainstorming with my professor Bill, and some online research - I'm trying to figure out a way to make this mockup materialize.  I've decided to start with focusing on the batting helmet.  Since I want to be able to accomplish this with as few things wired together as possible, I would like to put most of the hardware in the helmet.


Starting with the Arduino which I've worked with before, I've been researching using a wave shield for the audio in the helmet.  The audio of the different home run calls can be loaded onto an SD card and put into the wave shield.  I can plug in regular headphones and plant one in each ear guard of the helmet.  I'm not 100% sure how I'm going to wire all these parts into the helmet yet, as I'm still working on getting one to hack, but I figure worst case scenario I can stick it all on top.  (At least while I'm working everything out!)

Next, I have been trying to figure out how to trigger the audio.  Originally, I was thinking that there would be something inside the bat that would sense the way a person was swinging and that would start the audio.  I also thought about the possibility of using a motion sensing input device like a Kenect (but I don't have one of those to play with!)  So I took the idea of the motion sensor, but on a much smaller scale.  As I was researching the wave shield I came across this tutorial to make a Halloween pumpkin:  


I started look a little more into motion sensors as input devices.  I thought if I could find one that had a narrow range and put it into the bill of the batting helmet, facing down, then it would sense when the batter moved their arms and the bat, but not wider movements in the periphery.  I found this High Performance Ultrasonic Rangefinder (cool name, right?)  I don't know enough about this technology to be sure that it would be sensitive enough to catch the arm swing, but not surrounding movements.  I'll have to look into it a bit more.

Add a battery pack to this set-up and all the hardware would be right on the helmet.  (I'm starting to think with all the cool stuff happening in the helmet, perhaps I should name my project something other than Wonderboy...but I don't know of any cool batting helmet names...)  I just need to gather a few more parts and start playing around!

Tuesday, January 17, 2012

Pick Me Out A Winner Bobby

There are many ways in which people connect with the past.  It could be reading a book, looking at photographs, or visiting a site or museum.  In our Interactive Exhibit Design course, we have been encouraged to select an item we might find lying around our house, and by performing an action, imagine that this object somehow connects us to the past.  With the aid of imagination and a little magic - this ordinary item becomes a "history appliance."  

My colleagues have come up with some truly innovative ideas.  There are objects for every interest: the traveler, the java junkie, the fashionista, the meteorologist, and even those who would like to do more than just curl up with a good book.  With all these entertaining ideas, it is clear that we could take this "history appliance" in any possible (or seemingly impossible) direction we wanted.  However, there was one suggestion that caught my eye as I was reading the assignment, and as much as I brainstormed - I was continually drawn back to my original idea.  The suggestion: "an item of sports equipment" - the idea: a baseball bat.

 
Now, I had started to feel that baseball has played a much larger role in this blog than it actually does in my life.  Don't get me wrong - I'm a fan, and I interned at the Hall of Fame - but there are many other things that interest me, and I am certainly no baseball or sport historian.  But once this idea popped in my head I couldn't shake it.


Have you ever wondered what it would be like to hit that game-winning, record-breaking home run? (For my Canadian friends, it's the equivalent of a hat trick.)  With this bat you could experience that feeling.  Simply slip on this batting helmet (equipped with surround sound headphones), pick up the "Wonderboy", and swing for the fences!


The bat will gauge your swing and respond with the appropriate home run experience.  Perhaps yours is the "Shot heard round the world," and you hear this:



Or are you a lefty?  Take a swing and experience Roger Maris breaking Babe Ruth's record:


You could even tailor your experience, if there is a particular announcer you want to hear.  Consider Hank Aaron's 715th home run.  You could choose to hear Curt Gowdy (NBC), Milo Hamilton (Braves Radio Network), or Vin Scully (Dodgers Radio Network.)



For a more authentic experience, you can even opt out of the announcers, and keep it to the roar of the crowd and cheers of your teammates.  For a more in depth experience, screens could project the image of the stadium as you round the bases.  There are so many places the "Wonderboy" could take you.

There is something magical about listening to an exciting moment in sports history.  It's the kind of experience that makes the hair on your arms stand up.  The combination of your favorite player and that amazing announcer:




And then there are those moments I would rather not recreate with the "Wonderboy"...