Introduction: DIY Bike Tachometer

About: Hi, my name is Nikodem Bartnik. I'm 19 years old. I am into designing, making, programming and electronics. In the future, I want to start a company and make my own products. As for now, you can find my work o…

I will show you how to build a bike speedometer. It shows your speed,
the average speed,the temperature, the trip time and the total distance. You can change it using the button. Additionally, the speed is shown on a tachometer. I built it because I like building new things, I have not found anything like this on the internet so I want to show you how to build a good speedometer as the one on my bike is not as cool as I want :) . So let's get started.

Step 1: Parts:

This is a list of parts that you will need. They costed me about $ 40:

Step 2: Connection

I added a picture from Fritzing and verbal description of how to connect it. In the picture all red wires are connected to 5V, all blue cables are connected to GND.

  • LCD display:

VSS --> GND Arduino

VDP --> 5V Arduino

VO --> output potentiometer (potentiometer VCC -> 5V Arduino, potentiometer GND -> Arduino GND).

RS --> pin 12 Arduino

RW --> GND Arduino

E --> pin 11 Arduino

D4 --> pin 5 Arduino

D5 --> pin 4 Arduino

D6 --> pin 3 Arduino

D7 --> pin 2 Arduino

A --> 5V Arduino

K --> GND Arduino

  • Servo:

VCC --> 5V Arduino

mass --> GND Arduino

Data --> pin 6 Arduino

  • Thermometer:

VCC --> 5V Arduino

mass --> GND Arduino

Data --> pin 1 Arduino

data and power is connected via a 4.7 kΩresistor

  • Sensor on wheel:

one end -> 5V Arduino

second end -> A0 Arduino and resistor 1,2 kΩ

The other end of the resistor to ground in the Arduino

  • Button:

one end --> 5V Arduino

second end --> A1 Arduino

Step 3: Upload Code:

Below I added the code in comments there is an explanation.

links to the download libraries:

http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip

https://github.com/milesburton/Arduino-Temperature-Control-Library

If you have a different wheel diameter you have to change it. You can calculate it with this formula:

circuit = π*d*2,54 (d=diameter of your wheel, I multiplied it by 2.54 to get the result in meters).

/*
##################################################


Copyright by Nikodem Bartnik june 2014


##################################################
*/




//librarys
#include  < Servo.h>
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>


#define ONE_WIRE_BUS 1
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);


//LCD display pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//servo name
Servo myservo;
//definition of variables
 long previous, triptime, time, impulses;
 float speedometer, dist, aspeed;
 int servo;
 int screen=1;
 //If you have other circuit of wheel you need change it
 float circuit=2.0;
 double temperature;
 
 
 void setup() {


 lcd.begin(16, 2);</p><p>
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  
  //servo definition and setting the tachometer to 0
  myservo.attach(6); 
  myservo.write(180);
  lcd.print("Bike tachometer");
  delay(1000);
  lcd.setCursor(5, 1);
  lcd.print("V 1.0");
  delay(4000);
  lcd.clear();
  delay(500);
  lcd.setCursor(0, 0);
  lcd.print("Dist:");
 } 




 void loop() {
   //if wheel turns
   if(analogRead(A0)>=300){
      //number of turns++
      impulses++;
      //count turn time
    time=(millis()-previous);
    //count speed
    speedometer=(circuit / time)*3600.0;
  previous=millis();
    Tachometer();
  delay(100);
}

  Lcd(); 
   }
   
   //display speed on tachometer
   void Tachometer(){
     //map speed 0-180 to servo
  speedometer=int(speedometer);
  servo = map(speedometer, 0, 72, 180, 0);
  //setup servo
  myservo.write(servo);
   }
  
  
  
    void Lcd(){
       //when button is clicked
      if(analogRead(A1)>=1010){
        lcd.clear();
      screen++;
      if(screen==5){
          screen=1;
        }
      }
   
        if(screen==1){
        //displays speed
        lcd.setCursor(0, 1);
        lcd.print("Speed:");
        lcd.setCursor(7, 1);
        lcd.print(speedometer);
        lcd.print("km/h");
        }
        
        if(screen==2){
          
        //displays themperature
        temperature=sensors.getTempCByIndex(0);
        sensors.requestTemperatures(); 
        lcd.setCursor(0, 1);
        lcd.print("Temp:");
        lcd.setCursor(7, 1);
        lcd.print(temperature);
        lcd.print(" C");
        }
        
        if(screen==3){
          //displays averagr speed
        aspeed=dist/(millis()/1000.0)*3600.0;
        lcd.setCursor(0, 1);
        lcd.print("A.speed:");
        lcd.setCursor(8, 1);
        lcd.print(aspeed);
        lcd.print("km/h");
        }
        
        if(screen== 4){
          //diplays trip time
        triptime=millis()/60000;
        
        lcd.setCursor(0, 1);
        lcd.print("Time:");
        lcd.setCursor(7, 1);
        lcd.print(triptime);
    
        
        }
        
       
        lcd.setCursor(0, 0);
        lcd.print("Dist:");
        //calculation of the distance
       dist=impulses*circuit/1000.00;
       //dislays distance
       lcd.setCursor(6,0);
       lcd.print(dist);
       lcd.print("km");
      }                                                     

Step 4: Pack

As a cover I used a plastic box I bought for $ 1. I cut holes using a knife and a drill. Servo and LCD display I glued with a tape, tip I made with carton and painted it with paint. I did shield in Corel Draw X5 and I printed it, I added a PNG image, and Corel Draw file (if you want, you can edit it). I clipped the box to steering wheel on my bike and I soldered cables to the reed switch.

Step 5: Run It!

Now it is ready. All you need to do is turn it on and ride. Have fun with your speedometer. If you like this project, please vote on me.

Battery Powered Contest

Participated in the
Battery Powered Contest

Wheels Contest

Participated in the
Wheels Contest