Arduino and Ruby code to count open-close cycles of a target object.