Pocket Bike Speedometer Part 1

Ball mice were common a few years back. Their popularity was due to the absence of the optical mice. I remember those days when you have to constantly clean the rollers of the mouse because they will be so caked up with dirt that it doesn’t track smoothly anymore. And they were heavy because of the heavy ball in them and sometimes they can slip if you move your mouse too fast.


Ball mouse. It’s missing its PS2 port.

So what do you do with an obsolete piece of junk? You rip it out and see what you can salvage. I got here a HP ball mouse. Not sure what’s wrong with it but I picked it up from home last time I went back to Kuching. Thought it might come in handy. And I was right.


How fast can this bike go? Let’s find out.

It suddenly dawned to me how dangerous it was riding a bike without knowing how fast I was going. If I knew exactly how fast I was going, I can time those corners perfectly and achieve the fastest entry and exit speeds. And if I knew how fast I was going, I can probably judge the braking distance and that will allow me to brake later, shaving off precious lap time. Alright, I am being ridiculous but that’s not entirely impossible either.


There are 3 pairs of infrared receiver and transmitter here.

I checked the front brake disc and found that there are 15 holes per revolution. I did some calculation and found that by determining the rate of holes passing through the infrared sensors (transmitter and receiver pair), I can get a relatively accurate measurement of the speed of the bike.


The black one is the receiver and the transparent one is the transmitter.


Cameras can detect infrared. This is how it looks like when it’s on…


and when it’s off. Try pointing your remote control at your digital camera/camera phone. You’ll see that purplish glow.


Time to rob. Power supply providing the 5v to power the mouse circuit during testing.

I took the transmitter and receiver pair from the scroll wheel because they were the biggest. This is because the distance between the pair was larger to accommodate the scroll wheel. And through further testing, I discovered that the receiver will emit a small voltage when it is being flooded with infrared beam. Using that, I built a circuit to amplify the signal and fed it to a PIC 16F84A.


16F84A running at 4Mhz with 2 multiplexed 7-segment displays.

I haven’t had time to come out with the circuit diagram but rest assured it will be shown in Part 2. The PIC basically counts the holes passing by with respect to time. I have a short video sample below that shows the PIC COUNTING the number of holes it detected. It should increase by 15 for each wheel revolution.


Try not to multiplex displays if you can. The wiring is hell.

The next part is figuring out how to mount the sensors on the brake disc. I came up with a metal bracket to hold the sensors which was soldered to a board. I used excessive hotglue to keep it in place.


The black receiver is actually semi-transparent! You can see the infrared shining through it.


The board. I had to raise the sensors a bit to align with the holes on the brake disc.


And this is how it’s mounted on the bike. The metal bracket is connected to the front mud guard. I reused the mouse’s wire to connect the sensors.


A clearer picture of how it’s mounted.


And a closer view.

This concludes the first part. As of now, everything is already mounted on the bike and I have modified the PIC to make it display the speed instead of detecting the number of holes passing through the sensor. But I cannot test it out yet until I get its spark plug changed. Part 2 will include the circuit diagram and the code for the PIC which was written in mikroBasic. So stay tuned! Continue reading