HIGHFIV3D: Autonomous Reassurance Device – Part 2

(I only had a small speaker on hand, please forgive the audio)

I started working on the electronics component to the HighFiv3D machine this week. In my previous post, I went from using a piezo senseor to an accelerometer; then this week I decided to do a tilt sensor before getting frustrated trying to debounce it. So ACCELEROMETER it is…!

The first step was gathering parts. After a bit of advice from Gian Pablo and Rob, I figured I’d need an Arduino Uno, a Wave Shield and the accelerometer to start. We have some Arduinos on hand at Pier 9, but you can get everything from Adafruit, retailing for about $60.

The Wave Shield is basically another circuit board that sits directly on top of an Ardiuno and allows for .wav files to be played from an SD card. Now I can record the audio with my laptop, convert to the proper file type (.wav) and store them on an SD card for random play when prompted; in this case, when the accelerometer is moved.

I used Adafruit’s Wave Shield Kit, v.1.1, for which they have a great tutorial on soldering and building the actual board. If you can solder, it’s very simple. You’ll need a 2GB SD card (it can’t use anything larger) that is formatted – I used the SD formatter that Adafruit suggested, but Mac’s Disk Utility will work. Once the board was built per the instructions, I only added some female headers to make testing easier.

For the accelerometer, the only soldering that’s required is the wire leads that will run from the Arduino to the Shield/Arduino. I chose Yellow/Blue/Red for my X,Y and Z motions, black for power and green for ground (my electronics aptitude has been dictated by motorcycle wiring). Just leave a foot or so of wire slack to test the sensor.

 


 

 

 

 

 

 

 

 

 

 

 

 

 

Once the shield was finished, I started working on the coding. My programming experience is pretty limited (I once made a light blink with an Arduino, but that’s about it). Fortunately, there is a HUGE community with pre-written codes (Sketches), so you can get away with not having to completely write it yourself. I pulled from Adafruit’s example sketches for the Wave Shield and the accelerometer. The Arduino forums are a good resource too. But, since I sit next to him, I asked Gian Pablo to help me with the shield code first.

From Gian Pablo:

The great thing about using the Arduino for DIY projects is that it is so widely used that you can almost always find an example or project that to get you started. For this project, we used the WaveShield from Adafruit (https://www.adafruit.com/products/94) to provide audio output. It is a simple Arduino shield with an SD card slot and audio output. We connected an accelerometer, an ADXL335 on a breakout board.

For programming, we just used one of the examples from Adafruit as a starting point, in this case the Play6_HC example (http://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino/play6-hc). We wanted to modify it so that instead of reading a button press to trigger the audio response, it would respond to sudden motion of the accelerometer, and allow for some time for the hand to settle down each time (if someone gave it a good whack). This only required 3 lines of code, and then we had to make some slight changes to the rest of the program so that it would choose a random response each time.

After a couple of hours we were good to go!

The only .wav files I had on hand were from Star Wars and Nacho Libre (don’t ask), so I put them on the SD card, followed some directions, and voila… my little shield was talking to me. Incessantly.

Then, with the accelerometer tuned in – I was eventually able to activate random files by hitting the sensor. I was frustrated for 2 days because I kept getting an error, but we eventually realized that the file names were too long!! With just the shield, the file names didn’t matter, it just played whatever is on the card. However, with the accelerometer and randomization, the same files wouldn’t play because they were over 8 characters. Once I abbreviated them, it would play perfectly.

Next: Building the contraption with electronics.

Tell us what you Tink

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s