Getting That Hack on Pt. 2 — RFID testing, MP3 speaker add-on, and playing around with a potentiometer


So this post is going to be full of semi-random mini-hacking experiments since we’re trying to do a lot of stuff in parallel and, at the time, I didn’t have access to all the prototyping parts. Experimenting with parts allows one to understand the limitations and usefulness of different components and learn about the best way of implementing specific functionality into a project. I guess I’ll just start with the most simple experiment.

MP3 Speaker add-on

I was concerned that the flat, plasticky speaker from sparkfun wouldn’t pack enough oomph for our project, so I went ahead and pulled out the speakerphone speaker from an old nokia cell phone. Compared to the sparkfun speaker it is much smaller and compact, but WOW, does it pack a punch!



Unfortunately, although the nokia speaker didn’t sound as tinny as the sparkfun one, it was ridiculously quiet. And actually, both speakers were really quiet. Since I knew that the nokia speaker was capable of much louder sound, I had a lingering suspicion that the amplifier on the mp3 player was the culprit. Because you would normally connect headphones to it, it made sense that the amplifier was either passive or very minimal so as not to blow out your ears. Go figure.

<<The loudness of the nokia speaker has since been confirmed with the arduino. Yay! It’s perfect for this wearable project!>>

Potentiometer Visualization

I know I promised to show the zipper potentiometer, but it’s my teammate’s creation and I haven’t had a chance to take a picture and/or video of it in action. However, while she was working out the kinks, I thought it would be a good idea to figure out how to control my computer’s volume, as well as make a visualization, to visualize the potentiometer in action.

Of course, the arduino starter kit comes with a 1K and 10K knob potentiometer, so I used that for testing. The arduino side of things was easy since I just had to load up the basic analogRead sketch and connect an led to physically visualize the change of resistance. I made a simple modification (used absolute values) so that the LED blinked faster the higher the resistance (normally it’s the opposite).


Simplest setup ever…just three wires and connect to the computer!

I hadn’t used processing since March, so I was a little rusty with the code. Also, in my previous project the communication between the arduino and processing was simple because all I was sending was the state of a button and controlled a servo. I’m not one to re-invent the wheel and remembered that my professor from my prototyping class last quarter made a simple thermometer visualization for the class to play with. The TMP-36 temperature sensor varies voltage output proportionately to temperature and sends that analog data to the arduino. Although it’s electrical properties are different, like the potentiometer that analog data gets converted to a scale from 0-1023 by the arduino. PERFECT!


How it all looks in Processing. It’s really not that bad.

Obviously, I couldn’t use the sample code 1-to-1, but it gave me a great place to start and introduced me to the lovely function map(). What map() does is proportionately scale a number from one range to another range. So for example, if I have the number 5 on a range of 1 to 10 and wanted to map that to the range of 1 to 100, map() would figure that it was 50 for me on the fly. You can imagine how time-saving this is when your input number is changing constantly.

In the end it worked out really well. One caveat is that you have to make sure that  your computer’s audio is able to be controlled by Java …not sure how that all works behind the scenes, but I had to use the minim library’s gain function to control loudness since my audio card/driver didn’t support volume control via Java.

Potentiometer Visualization test from Tar G on Vimeo.

You can see a video of the setup in action here. Excuse the visualization delay in the video–I’m running off of a 5 year-old Lenovo X200 which isn’t exactly the most high-end machine. But it sure gets the job done!

*UPDATE: here’s how the zipper potentiometer looks.

Ant's eye view of the zipper potentiometer

Ant’s eye view of the zipper potentiometer

After hooking it up to my computer, I’m glad to say everything worked great!

RFID: Tap that password

Ok, this was actually one of my favorite hacks of the whole project. There’s just something magical about wireless communication, even if it’s used to simply switch on a light. In a world of cell phones and WiFi, we kind of take for granted how powerful that magic is and only realize the freedom it affords us when we’re forced to be tethered to it. I haven’t owned a corded phone in 10 years, but whenever I’m in a room where I have to plug in my laptop to an ethernet cable, I curse the building for making me sit near the wall.


Yep, those fancy expressPay credit card machines use RFID

There are tons of RFID readers for the arduino, but most of them are over $20, which I think is way too much for a prototype. Luckily, China has mastered the art of cheap electronics and a very simple RFID reader can be found for $3 direct from China or $5-6 from the States. The RFID reader is the same one that’s marketed as NFC for a lot of smartphones and operates on the 13.53MHz radio frequency.


MiFare RFIC RC522 13.53Mhz Module for the Arduino. Cheap and works great!

Like most cheap electronic components from China, official documentation for this thing is non-existent and with my limited tech knowledge, I actually took a huge risk buying it. Luckily, past experience buying popular items like this on eBay has proved fruitful since there usually hacker communities who put all the pieces together for you. After tons of online research here and here and here (to name a few), I found out that some nice person (or people) made a library to interface directly with this MiFare RFID RC522 module. So thank you Miguel Balboa for making my life and many others so much easier!


Watch where all those connections go. The library states which pins go where. SS (Slave Select) pin can use the SDA (Serial DAta) pin.

One piece of advice is that you have to solder either wires or pins directly to the card to ensure that all your connections are reliable. I was lazy and made the mistake of trying to push the circle contacts against the pin headers as a way to test the card, but obviously it didn’t work. It only occurred to me after hours of troubleshooting that I should probably just solder everything directly. Another homage to the Ant and the Grasshopper

Of course, the code I used for this was modified from one I found in a youtube video here and from the example sketches provided in the rfid library. It saved me tons of time trying to figure out how to even call functions for the card and enabled me to do a quickie test with two leds and two rfid cards. Huzzah!


Leave a Reply

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

You are commenting using your 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