Step 7: Calibration

Step 8: How to use

Turn on the device. Move it on a line gently to measure the distance traveled. Press the "RESET" button to set display number to zero. ...

I always was thinking of a measuring tape that never ends and be able to measure very long things. So I decided to make a small odometer and use it as a digital measuring tape.
I used a PIC16F819 microcontroller and a sensor from an old computer mouse (the remaining parts of one of my other projects Crazy Mouse) to make this simple measuring tape.
Do you want to make yourself? If yes read the rest of this instructable.

Hello dear Vahid. Thank you for sharing this. I really liked your project and i'm going to make it. But I need to measure small distances with millimetric precision. I wonder if it's possible to change the code so that it can measure from 1 to 999 millimeters?

I'm trying to make this project but am running into a problem. How can i check if the IR receiver and transmitter are working or not? What are the voltages on their pins supposed to be if i apply a voltage of 3 volts after putting them on a breadboard?

If you found this components in a mouse you can take a look at mouse board to find resistors you need to use (most of mouses are 5V). In my circuit I used a 470 ohm resistor for transmitter, no resistors for receivers and 4.5V battery pack. You can see IR transmitter light using a digital camera or mobile phone camera. You can test receivers by connecting it to an ohmmeter and any IR remote control like TV remote control. If you have the components ID search for their datasheet on the Internet.

This is the maximum distance limit, if the distance is 10 meters it could not be displayed on 3 digit seven segment display so reset the number to zero again. And also if you do not do this the "Ticks" variable may be overflow, or you must use variable type with more capacity.

At the beginning of the program I configured PIC to go to interrupt routine every time the state of B0 pin (that is connected to oner of receivers) changes from 0 to 1. "if (INTCON.INTF)" ensures that B0 pin changed. "if (Sensor1)" means that if the other receiver that is connected to A4 pin is 1. "if (RButton)" means that is user held down the Reset button in order to calibrate. When the B0 pin changes from 0 to 1, if the A0 pin is 1 it means that wheel if rotating forward, and if the A0 pin is 0 it means that wheel if rotating backward. So if the user wants to calibrate the program changes the Ticks/Meter constant that is stored in the ROM of PIC, and if the user want to measure (not holding down Reset button) program counts the number of ticks made by rotating toothed wheel and convert it to meter using the conversion ratio.