Picture of Digital Measuring Tape
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.
Remove these adsRemove these ads by Signing Up

Step 1: What you need

Picture of What you need
To make this measuring tape you need the following components and tools:
  • Printed circuits (find files in the next step)
  • Copper board
  • Sandpaper
  • Iron
  • Circuit board acid
  • 1mm drill
  • Soldering tools
  • 1x PIC16F819 microcontroller + socket
  • An old mouse (or one of its IR shaft encoders)
  • 3x BC547 transistors
  • 3x common anode 7 segments
  • 1x 100uF electrolyte capacitor
  • 1x 470ohm resistor (1/8 watt)
  • 7x 10k resistors (1/8 watt)
  • 2x Simple push buttons
  • 1x Simple switch
  • 2x AA batteries with a battery holder
  • 1x Wheel (+ maybe some gears)
  • A box for this measuring tape

Step 2: Making the PCB

Picture of Making the PCB
First you need to make a PCB. Here is a good instructable for making PCBs.
  1. Print the circuit on a glossy paper with a laser printer without scaling.
  2. Cut some copper board and clear it with sandpaper.
  3. Put the printed circuit on it.
  4. Press the hot iron on the board.
  5. Remove the papers.
  6. Soak boards in acid and wait till visible copper disappears.
  7. Wash the boards.
  8. Drill the holes.
  9. Clear the board with sandpaper.

Step 3: Soldering components

Picture of Soldering components
IR Sensor.png
Now it's time to solder components on the board. Here is a good instructable for Soldering.
  1. Solder the mouse IR transmitter and receiver on the board.
  2. Solder 470ohm resistor behind the IR transmitter.
  3. Solder 10k resistors on the board.
  4. Solder some wires on the lines that connect two holes together. (jumpers)
  5. Solder microcontroller socket on the board in a correct direction.
  6. Solder seven segments.
  7. Solder transistors.
  8. Solder buttons with some wire.
  9. Solder the capacitor on the board in a correct direction.
  10. At last solder the switch to the battery holder and solder its wires to the BAT terminal.
1-40 of 64Next »

can i replace pic16F819 with pic16F627? and can you sent me your schematic project to thanks

Yes, but you must make little changes to circuit diagram and program. Try to DIY!
kooroshi609 months ago

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?


vahid_you2004 (author)  kooroshi609 months ago
Yes, You must change the software and gears ratio.

what software you used to sketch the circuit?

vahid_you2004 (author)  muhammad.akmalmix10 months ago

what software you used to sketch the circuit?

what software you used to sketch the circuit?

what software you used to sketch the circuit?

what software you used to sketch the circuit?

what software you used to sketch the circuit?

what software you used to sketch the circuit?

what software you used to sketch the circuit?

jaysonM1 year ago


vahid_you2004 (author)  jaysonM1 year ago

Yes, but you must design new circuit and write new program.

afroze92 years ago
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?
vahid_you2004 (author)  afroze92 years ago
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.
can u explain it to me, thanks a lot mr.

LRButton = 0;
if (EEPROM_Read(0) == CorrectROMValue)
unsigned short int k;
OneMeterTicks = EEPROM_Read(1);
k = EEPROM_Read(2);
OneMeterTicks = (OneMeterTicks << 8) + k;
LOneMeterTicks = OneMeterTicks;
while (1)
if ((!RButton) && LRButton)
Ticks = 0;
if (OneMeterTicks != LOneMeterTicks)
EEPROM_Write(0, CorrectROMValue);
EEPROM_Write(1, (unsigned short)(OneMeterTicks >> 8));
EEPROM_Write(2, (unsigned short)OneMeterTicks);
LOneMeterTicks = OneMeterTicks;
LRButton = RButton;
vahid_you2004 (author)  zulwaqaromar2 years ago
LRButton = 0; (*Initial assigment of LRButton variable*)
if (EEPROM_Read(0) == CorrectROMValue) (*if the user did not calibrated yet the value stored in posiition 0 of EEPROM is zero so if only already calibared read calibration value from EEPROM, CorrectROMValue is an arbitrary constant value*)
unsigned short int k;
OneMeterTicks = EEPROM_Read(1); (*read first byte of calibrated value fromm EEPROM*)
k = EEPROM_Read(2); (*read 2nd byte of calibrated value fromm EEPROM*)
OneMeterTicks = (OneMeterTicks << 8) + k; (*join 2 bytes together*)
LOneMeterTicks = OneMeterTicks; (*store OneMeterTicks value to LOneMeterTicks*)
while (1) (* the endless loop to run the reset of the program*)
if ((!RButton) && LRButton) (*if RButton is Up (=0) but in last state was down (LRButton=1)*)
Ticks = 0; (*zero the display value*)
if (OneMeterTicks != LOneMeterTicks) (*if OneMeterTicks not equals last saved OneMeterTicks means that the user changed calibration value so it must be saved to EEPROM*)
EEPROM_Write(0, CorrectROMValue); (*write the value that indicates already calibrated to EEPROM*)
EEPROM_Write(1, (unsigned short)(OneMeterTicks >> 8)); (*write 1st byte of calibration value to EEPROM*)
EEPROM_Write(2, (unsigned short)OneMeterTicks); (*write 2nd byte of calibration value to EEPROM*)
LOneMeterTicks = OneMeterTicks; (*store new value of OneMeterTicks value to LOneMeterTicks*)
LRButton = RButton; (*store the sate of RButton in LRButton*)
if (abs(Ticks) >= OneMeterTicks * 10) Ticks = 0;

what is means with this coding
vahid_you2004 (author)  zulwaqaromar2 years ago
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.
can i use 1 transmitter n 1 receiver only?
vahid_you2004 (author)  zulwaqaromar2 years ago
No, you must use 2 receivers in order to detect direction of movement. All IR encoders like that I used have a component that contains at least 2 receivers in a block.
if i need use LCD which part of programming i need to change
vahid_you2004 (author)  zulwaqaromar2 years ago

if (Cycle == DigitChangeCycle)
SS1 = 0;
SS2 = 0;
SS3 = 0;
if (Ticks < 0)
n = -Ticks;
n = Ticks;
n *= 100;
if (UButton == 1)
n /= (unsigned long int)(OneMeterTicks * 2.54);
n /= (unsigned long int)OneMeterTicks;
Digit[2] = n / 100;
n = n % 100;
Digit[1] = n / 10;
Digit[0] = n % 10;
dig = Digit[DigitIndex];
SSA = ((dig == 1) || (dig == 4));
SSB = ((dig == 5) || (dig == 6));
SSC = (dig == 2);
SSD = ((dig == 1) || (dig == 4) || (dig == 7));
SSE = ((dig != 0) && (dig != 2) && (dig != 6) && (dig != 8));
SSF = ((dig == 1) || (dig == 2) || (dig == 3));
SSG = ((dig == 0) || (dig == 1) || (dig == 7));
if (DigitIndex == 0) SS1 = 1;
if (DigitIndex == 1) SS2 = 1;
if (DigitIndex == 2) SS3 = 1;
Cycle = 0;
if (DigitIndex == 3) DigitIndex = 0;
if ((DigitIndex == 2) && (Digit[2] == 0)) DigitIndex = 0;
if ((DigitIndex == 1) && (Digit[2] == 0) && (Digit[1] == 0)) DigitIndex = 0;


if (Ticks < 0)
n = -Ticks;
n = Ticks;
n *= 100;
if (UButton == 1)
n /= (unsigned long int)(OneMeterTicks * 2.54);
n /= (unsigned long int)OneMeterTicks;
Your code to display n on the LCD
i dont understand with Void intterupt part..
vahid_you2004 (author)  zulwaqaromar2 years ago
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.
is it true, i just need 1 set of optical sensor (1 transmitter and 1 receiver)...or i need 2 set..
vahid_you2004 (author)  zulwaqaromar2 years ago
you need 1 transmitter and 2 receivers, the receiver part in old mouses is a single component that contains 2 receivers inside.
hello, i dont understand for "if(Rbutton)?...can u explain it to me..
vahid_you2004 (author)  zulwaqaromar2 years ago
If you download and see the rest of code, you'll see that RButton is defined as A2 pin that is connected to Reset (Calibrate) button, so this line means that "if that button is closed".
kALuN_pUD2 years ago
hi, I want just to ask if the program is running? or there's some changes ?
noykolz2 years ago
Hello. are the IR receiver and the IR transmitter both found in the IR shaft encoder from mouse?
if not, what is that IR shaft encoder a trasmitter or a receiver? Thanks in advance for the answer.
vahid_you2004 (author)  noykolz2 years ago
Hi, Yes, You can find all these 3 components in a old mouse, shaft encoder is the toothed wheel, and transmitter and receiver are the components that toothed wheel is among them.
vjeamrhasty2 years ago
nice project!
i just want to ask if we can use meter, ft, inches, cm, etc. units at the same time?
vahid_you2004 (author)  vjeamrhasty2 years ago
Thanks, Yes, All you have to do is to add conversion factors between units to the program and use a display with more capacity like LCD.
can i replace PIC16F819 with PIC16F84A ?
vahid_you2004 (author)  vjeamrhasty2 years ago
Yes, But a few changes must be made in the source code.
pmounica3 years ago
how long does it took to finish
can ii do it in less than a 3 weeks
vahid_you2004 (author)  pmounica3 years ago
If you have all things needed, you can do it in a day.
1-40 of 64Next »