Recently, I needed to count open-close machine cycles for a customer. We couldn’t trust the machine readouts, so we needed an external device to count the cycles accurately. This device also needed to be built quickly and easily moved from machine to machine. Those requirements pushed my thoughts toward using an ultrasonic sensor and an Arduino. Although Ruby is not the first language I normally think of for the client-side of something like this, the customer uses Ruby extensively in their enterprise. I knew they???d be able to support a Ruby app without any trouble. Below is a trimmed down version of what my associate Tom and I came up with.