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!