Tuesday, December 25, 2007

Arduino with Radio Shack Parallax accelerometer

I think the theme for today will be rapid prototyping and speed. In between Christmas celebrations, and holiday movie re-runs, I've run back to my room to whip together some circuits. It's insane how easy it is to build functioning devices with the Arduino! Case in point: ~30 minutes tops to build a fully-functioning hand-held accelerometer driven device.

I started with the Parallax accelerometer, which I picked up from Radio Shack. The full name is "Memsic 2125 Dual-Axis Accelerometer".




Using the two diagrams above as the theory, and borrowing code from the Arduino community (special thanks to Marcos Yarza for the initial code, which I've cleaned up below). The first step was the wire up the chip to the board. That was easy, since the kit comes with a pinout sheet: two pins are tied to ground, one to +5V, Tout is ignored for now, which leaves Yout and Xout. Xout and Yout are PWM outputs that, according to the second schematic above, output a variable width pulse based on their reading. I wired it up, and then read the values out to the serial port:



Once I had ranges for the values, I got a little creative and threw in some condition "if" statements, tied to LEDs on the prototyping board. Now, an LED should illuminate whenever the board is tilted in that direction:



Here is the source code I pulled together. I moved around some of the original code, to make it more cut-and-paste-y into your own projects.

Arduino with Radio Shack Parallax motion sensor

Well, that didn't take long. It's been less than a week, and I'm already feeling quite familiar with the Arduino platform. I just mashed this circuit together in less than 5 minutes (in fact it took longer to video tape than it did to make)!

I picked up the new Parallax motion sensor circuit yesterday for $10 from Radio Shack. Parallax has done a great job of making these chips accessible and easy to use by making the documentation available online. I would recommend all parts vendors to be this accessible, in fact, since it makes circuitry approachable to the novice, and reduces headaches for experts too:







Here's a video of the motion sensor "in action" (pardon the pun):



The device only has 3 pins: one that connects to ground, one that connects to +5V, and a signl pin that I've connected to Arduino pin 8. Then, I've connected an LED to Arduino pin 5, which I turn on for a second whenever the motion sensor is triggered. Here's the source code.

Arduino with Parallax Sonar sensor

Yesterday, I picked up one of the heavily-advertised Parallax PING Ultrasonic sonar sensors from Radio Shack, and wanted to see how easy (or difficult) it would be to get operating with the Arduino. As it turned out, it was incredibly easy - in fact, it took less than 15 minutes of coding to get operating, and all I needed was the PDF spec-sheet from Parallax:


I plugged the sonar module into the top of the breadboard, wired ground, wired +5V, and then connected a wire from the signal port to the Arduino's pin 8. 15 minutes later, here's a video of me moving the sensor towards and away from my laptop's monitor:



After I wrote my own code, I found a slightly more elegant way to wait and count the length of the return pulse - there's Open Source community in action - thanks!

Anyway, here's my code - I've uploaded it to Liquidware.

Monday, December 24, 2007

Video: Blinking an LED

I walked through the blink-the-LED tutorial from LadyAda, and recorded the steps I took to upload, and tweak the program slightly. As I mentioned in my previous post, this reveals a lot about the usability and "approachability" of the Arduino platform. The PC program is easy to use, and changes are almost immediately visible on the USB-connected Arduino, effectively decreasing coding-demo-operation cycles to a few seconds. In my PIC days, I was used to coding-compiling-burning to chip on a programmer-inserting chip into circuit-connecting power-operation, which took at least 5 minutes per iteration. You can see for yourself below:

Here's a video of the blink program:


And this video illustrates slight tweaking of the program, and how quickly the changes can be seen on the board:

Going through the motions

I figured I'd start off slow by following a decent set of tutorials on the Arduino. Independent of experience, it's always been helpful to me to get a decent idea of "platform workflow", or how engineers and designers approach development on a platform by walking through a few examples. For instance, I've noticed that PIC, BASIC Stamp, Motorolla, and ARM hackers tend to approach the design process differently: Stamp guys tend to prototype on the fly, and write code while they run, PIC guys tend to draw schematics before building, and Motorolla /ARM (and other low-complexity sub-PowerPC/x86) tend to go through more elaborate pre-design, pseudo code, meta/block diagram, and schematic drawing before finally building and coding.

For purposes of the Arduino, I've chosen to start here:

LadyAda Arduino Tutorials

I found the link on the Arduino main tutorial page

Saturday, December 22, 2007

Expansion boards (shields) in the mail

One of the first things I'd like to understand is the expansion capabilities currently available for the Arduino. In the Arduino community, these snap-on boards are called "shields", and they fit directly on top of the Arduino, taking power and some IO pins from the base board and passing them through to the shield circuit.

There are a few boards out there today, so I picked up:


They should come in over the next few weeks, and when they do, I'll be sure to provide a write-up and take plenty of pictures. I'll try to do my best to stay on top of all the available shields on the market, as well as those "in the pipeline."

Video: Plugging it in

Here's a video I took of me plugging it in for the first time - enjoy:

Review: Adafruit Arduino Starter Pack

Last night, I opened the Arduino Starter pack, and took a video of me unpacking it. It's a great kit, and worked right out of the box:

NYC Arduino Hacklabs

Update: Whoa! I originally posted about a Hacklab upcoming in January, but got the date wrong. I'll be sure to update as soon as I hear about the first one in 2008. Thanks for keeping me up to speed...

The next one will be announced here


~~~~~~~~~~~

I just heard about an event upcoming in NYC, called the Arduino Hacklab:

http://idmi.poly.edu/node/88

Sounds like it'll be a great opportunity to meet other Arduino fans, and also learn some tips and tricks for beginners (and I'm not opposed to some advanced tricks too).

Friday, December 21, 2007

Arduino, here I come!

I've just received my Arduino in the mail, from a company here in NYC called Adafruit Industries. This officially will begin my adventure into the world of Arduino. In posts to come, I'll start uploading pictures and videos of my experiences with the Arduino.

For those who aren't familiar, the Arduino is an Open Source hardware development board. It has been featured in Make Magazine and Make Blog many times, and there are a number of videos online too.

As for me, I've been a circuit hobbyist for over a decade, and after teaching myself using RadioShack breadboards back in the early 90's, went on to get my official EE bachelors degree. This whole time, I've been an avid PIC user, so this will be a fresh start and something entirely new for me. I can't wait!