Building the Rodentometer – Part 2: The Hardware

The Input

(This is Part Two in an ongoing series which starts at Part One).

To answer all the questions raised in part one, there is only one thing we really need to know:

How far does our hamster run in a particular period of time?

The “how far” part should be quite easy, because the little critter is running in a fixed wheel – no need for a micro-GPS tracking bug here.  Some mechanism for counting how many times the wheel turns should be sufficient.

So, how can we measure the rotations of a wheel like this?  Well there are several ways, but the one I’ve gone for to start with, due both to the simplicity and the fact that I have the parts on-hand, is the reed switch.

The Humble Reed Switch

A reed switch is a simple device.  It’s essentially just two bits of metal in a sealed glass tube, and the ends overlap slightly but don’t quite touch – the switch is open.  If you wave a magnet around near them though, they magnetise and stick together.  CLICK – switch closed.

What this means is that we don’t need to have any direct mechanical contact between the stationary Rodentometer and the spinning wheel.  We can attach the reed switch to the edge of the back part of the wheel (the bit that’s not spinning) and glue a little magnet to the spinning part of the wheel.  Every time the wheel turns, the magnet will pass near the switch and momentarily close it.  Those little “ticks” of the switch is what we will count – each tick is another 54cm travelled.

The Similarly Humble Push Button

A little switch on the project will allow for easy resetting of the statistics, without the vulgar resort of just pulling the plug. I used ones very similar to those pictured above, but really any sort of simple push-to-make switch will do.

The Brains

As already mentioned in Part One, the brains of the operation will be an Arduino Uno, featuring the ATmega328 microprocessor. This will handle all the input sensing, the distance and timing calculations and finally some sort of output.The Arduino Uno

The Output

It’s all well and good for the Arduino to know how many revolutions of the wheel there have been, or that the hamster has run for 93km since the weekend, but how are we going to find out?  For that, I’ve decided on several options, and we’ll be seeing all three.

Serial Data

As long as the Arduino is connected to a computer using the USB, it’s really easy to talk to it using the Serial port.  In the code, we just make sure we configure the board to “talk serial”:

void setup() {
  Serial.begin(115200);
}

And then whenever we want to send any messages to the computer we can just do something like:

Serial.print("The current revolution counter is: ");
Serial.println(currentCount);

And then we’ll see that appear in our Arduino IDE as “The current revolution counter is: 123″.

This is basically the main debugging technique for Arduino code – you can sprinkle the Serial.print commands throughout the code and you can see what it’s up to in the IDE.

LCD Display

The more fancy feedback will come from the SparkFun Graphical LCD, which is a nice little 128×64 pixel display, which when coupled with the “Serial Backpack” means you only need two Arduino pins to send it commands.  You can draw all sorts of pretty shapes…

  1. :grin: I literally LOLed when I stumbled on this page, as my first arduino project was to build the KnucklesOmeter for my hedgehog. I used an Arduino with a optical sensor from a copy machine, a little tab on his wheel, and an Ethernet shield with the Twitter library, so that he can post a tweet when he stops running for more than a minute (he likes to stop and look around now and then) to let his twitter followers know how far he has run. It has an RTC on it so that it can track his statistics over time as well (I have run 45.7k since mm/dd/yy)

  2. Most important part was missing, what was the result?
    How fast and how long?

Leave a Comment

3 × 1 =


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>