Introduction: DIY Bike Speedometer

About: I'm a high school student from Athens, Greece. I like to play arround with electronics, computers and programming. I have created some websites for school clubs and for personal use and i have participated 3 t…

Hello people,

I just finished my latest project: A speedometer for my bike. It uses an attiny84 chip as its main processor and an 74ls47 chip as a driver for its 7-Segment Display (7SD from now on). If you have the parts it's a project you can finish in a day. It requires simple arduino coding skills, intermediate soldering skills and some knowledge on electronics but we are going to cover everything in this instructable. The total cost of the project is around 15€.

Parts List:

  • Attiny84: 2.60€
  • 74ls47 or 7447 IC (If using a common cathode 7SD go with the 4511 IC): 2.20€
  • Triple Digit 7-Segment Display (Common anode displays are easier to find and that's what I used but you can go with a common cathode if you buy the correct driver as mentioned above): 1.40€
  • 14 pin DIP Socket: 0.06€
  • 16 pin DIP Socket: 0.08€
  • Magnetic Switch (This is a tricky one but you can see what I mean here): 5.00€
  • 1 or more (The more the better) small neodinium magnets: 0.00 (I found mine in an old toy)
  • L7805CV 5V Voltage Regulator: 0.4€
  • 1uF Electrolytic Capacitor: 0.06€
  • 10uF Electrolytic Capacitor: 0.05€
  • 1KΩhm Resistor: 0.01€
  • (OPTIONAL) 3 330Ωhm Resistors
  • Mini slide switch: 0.20€
  • Right angle pin headers: 0.30€
  • 4 pin Female Dupont Terminal and Connector: 0.40€
  • A piece of prototyping board (I used about 8x4cm): 1.5€
  • Heatshrink
  • TOTAL: 14.26


  • Soldering Iron and Solder
  • Drill
  • Pliers
  • Wire Stripper
  • Cutters
  • Multimeter (To test connections)

Step 1: Circuit: Power Supply

First things first. The attiny84 works just like an arduino and it needs constant 5V power supply and so does the 7447. We are going to use the L7805CV Voltage Regulator the two capacitors and the switch. The schematic is pretty straight forward: You connect the ground of the two capacitors to the ground pin of the regulator, the positive side of the 10uF to the input and the positive side of the 1uF to the output. Now the 9V supply from battery is going to come through a connector so now its a good time to start soldering. On one side of your prototyping board you want to fit as many things as possible. Solder your regulator after bending its pins in the middle of the board in order to fit it without the heatshink sticking out. Solder the two capacitors in front of it. Leave some space for the switch too. Solder 4 right-angle headers on the top of your circuit. These will provide power and signal from the sensor that will go on your bike. It is important to decide now and remember which pin is used for what. The pin that you chose that is used for positive side of your battery is connected to the middle pin of your switch and one of the edge pins of the switch go to the input of the voltage regulator. The pin you chose for the negative end of the battery goes to the ground pin of the regulator and your power supply is done.

Step 2: Circuit: Display

On the other side of the board you will want to solder your 7SD leaving some space above for a hole. Next to it solder the 16 pin DIP socket for the 74ls47 or 7447 IC. Connecting the sockets pins is the same as connecting the ICs pins but you can remove the IC anytime. The IC is going to face up so the pins that connect to the 7SD are next to it. Now connect the a,b,c... pins of the display to the corresponding pins on the IC. Remember that the pin order gets mirrored when you flip the board as you are looking at it from behind. Connect pin 16 of the 74ls47/7447 to the output of the regulator and pin 8 to ground. If you are working with a common cathode 7SD you may want to see how it is connected to the appropriate IC (4511) here. It's pretty much the same.

Image sources:

Step 3: Circuit: Attiny

The attiny84 is a board that works just like an Arduino but it has fewer pins and it costs WAY less. I will explain how you connect it right away but first you might want to see how to program it using an Arduino UNO as an ISP here (use 8MHz instead of 1MHz as shown in the tutorial). Solder the remaining socket for the attiny between the power supply and the 7447. The attiny is going to be installed face up too so the first of its pins are near the 7447s inputs. Connect the pins a,b,c and d (actual pins 7, 1, 2, 6) from the 7447 to digital pins 0,1,2 and 3 (actual pins 13, 12, 11 and 10) of the attiny and pins 1 and 14 output and ground of the regulator respectively. Next you need to connect the anode pins of the 7SD to the attiny as shown on the diagram. Connect the pins that correspond to anodes 1, 2 and 3 of the 7SD as shown on the diagram to digital pins 4, 5 and 6 of the attiny (actual pins 9, 8 and 7). Last thing for the display is to connect the dp pin of the 7SD to digital pin 7 of the attiny (actual pin 6).

Image sources:

Step 4: Circuit: Sensor

The sensor is not going to be directly connected to the circuit but through the remaining 2 pins on the header you shouldered on the first step. Again choose the pin used for power and for signal. The connection here is a bit tricky so I'm providing a schematic. You basically connect the power pin to the output of the voltage regulator and the signal pin to digital pin 8 of the attiny84 (actual pin 5). You also connect the signal pin to ground with the 1KΩhm resistor. Have a look at the schematic it makes more sense. The connection is similar to the connection of a button to the Arduino as explained on this Arduino tutorial.

Step 5: Cable

I made a pretty messy cable to connect the sensor and the battery to the board but this helped me with cable management on the bike. First you need to make the dupont cables. Follow the instructions here. First connect the 9V battery holder and attach it to the right position on the dupont connector. Remember your connections on the header and plan the cable that will fit there. You want the + and - side of the battery to appropriately go to the INPUT and GROUND of the regulator. Next connect two small wires to the remaining connectors. You will later use them to connect the sensor. Don't forget to secure everything with electrical tape and heat shrink.

Step 6: Sensor

First of all find a nice spot on your bike, near the front or back wheel where you can attach the sensor. Screw the magnetic switch to a nice, small, flat piece of wood and secure it next to the wheel. You want it to be as close to the spokes as possible without touching them. Manage your cables and secure the sensor firmly so nothing interferes with the bikes mechanics. Now you need to attach the small, neodymium magnets on the bikes spokes. If you choose to go with only one you can place it wherever you like but if you want to go with more for better accuracy be sure that the angle between every magnet is equal. For example, if you go with two like I did place them on the bikes diameter. You want your magnets to be in the appropriate distance from the wheel's center to trigger the switch. Move the wheel around and find the right position. You might also want to move your sensor further away from the wheel's spokes to be out of the magnets way when the wheel spins but not too far away for the switch to get triggered. See the pictures on how I did it.

Step 7: Putting Everything Together

When you have your sensor installed you want to connect it to the cable you made on a previous step. Use as much wire as you need to connect the output of the switch and the two small wires you left unconnected on your wire. Secure everything with zip ties on your bike, use electrical tape and heatshrink to insulate your connections and be sure that nothing interferes with the bikes mechanism.

Step 8: Coding

I'm providing the full code for your speedometer to work. Use the tutorial mentioned in a previous step to program your attiny84 and don't forget to burn the bootloader before first use. I will keep the code updated with fixes and recommendations!

**Skip this if you don't care about the physics**

The speed is calculated using the formula for uniform circular motion. The rotational speed ω is calculated by dividing 2π by the duration of a full circle. A full circle is 360 degrees or 2π rad so dividing 2π by T, the duration of one full circle, with get the rotational speed of the wheel. The rotational speed of the wheel can be measured on any point on the radius of the wheel because it spins with the same speed as a solid object. Although the linear speed (u) is different on any point on the radius of the wheel is different. We know that the perimeter of a circle is calculated by multiplying the radius (R) of the circle with 2π. If we divide this by T we get the linear speed of the wheel and therefore of the bike. So we get the formula u=(2*π*R)/T that can be transformed to u=ω*R. So by knowing the time it takes for a whole circle we can calculate the speed of the bike. Know if you use more than one magnet the sensor signals not every full circle but every half or third or quarter circle. So we measure T/2 or T/3 or T/4 making the measurement more reliable. The formula is corrected to u=ω*R*(number of magnets).

If you want any more explanation on the code ask in the comments.

The code is provided under Attribution-NonCommercial-NoDerivatives 4.0 International Licence.

Step 9: Done.

You are basically done with this project. Go ahead and make a small hole on the right upper corner of your speedometer. When you attach it to your bike on the cable you made, use a zip tie to secure it on the bikes steering wheel in order to keep your cable unstressed. This allows you to remove your speedometer from your bike to fix it and flash it with updates!

Maker Olympics Contest 2016

Participated in the
Maker Olympics Contest 2016