Arduino Bike Speedometer by amandaghassaei
Featured
main.jpg
IMG_9279 copy.jpg
Monitor your road speed using the Arduino. This project uses a magnetic switch (also called a reed switch) to measure the speed of one of the bike's wheels.  The Arduino calculates the mph, and send this information out to the LCD screen on the handlebars as you ride.  It is compatible with any kind of bike/wheel, simply enter the radius of the wheel in the firmware to calibrate the device for your setup.



Parts List:

(1x) Arduino Uno REV 3 Radioshack 276-128
(1x) Switch-Magnetic Reed Radioshack 55050593
(1x) 10K Ohm 1/4-Watt Carbon Film Resistor Radioshack #271-1335
(1x) 9V Alkaline Battery Radioshack #23-866
(1x) Heavy-Duty 9V Snap Connectors Radioshack #270-324
(1x) PC Board with Copper Radioshack #276-147
(1x) Parallax 27977-RT Serial Backlit LCD Radioshack 276-120
(x2) SPST PC-Mountable Submini Toggle Switch Radioshack #275-645
(2x) Male Header Pins Jameco 103393
(1x) Female Pin Sockets Jameco 308567

Additional Materials:
22 Gauge Wire Radioshack #278-1224
Solder Radioshack #64-013
sand paper
plywood
wood glue
hot glue
screws
zip ties
sugru

Download Arduino IDE

 
Remove these adsRemove these ads by Signing Up

Step 1: Schematic

schematic.jpg
The schematic for this project is shown above.

It consists of three switches:
-one to connect to a 9V power supply
-one to switch the backlight of the LCD on and off
-a magnetic switch (called a reed switch) which closes each time the wheel completes one full rotation.

The Parallex LCD is designed to connect to the arduino using only three pins (ignore the labels and the other pins int his schematic).  One to 5V, one to ground, and a third to serial out (TX)- on the arduino, serial out is digital pin 1.

10kOhm resistors are connected to the reed and backlight switches to prevent excess current between 5V and ground (you should never directly connect 5V and ground on the arduino!)
1-40 of 75Next »
allenkevan24 says: May 11, 2013. 11:23 PM
So far I have everything working the way it should, but i can't get my lcd display to display anything at all but the backlight works fine. Any advice?
amandaghassaei (author) says: May 12, 2013. 11:19 AM
it's the same lcd? you might try some of these sketches just to make sure it's working.
http://learn.parallax.com/KickStart/27977
12niraj12 says: May 5, 2013. 6:19 AM
what is the total power lost in the ARDUINO developed speedometer.
col0n says: Apr 17, 2013. 6:39 AM
Would this be possible to make with an arduino micro?
amandaghassaei (author) says: Apr 17, 2013. 9:10 AM
Yes
shad0w88 says: Jul 26, 2012. 3:00 PM
Nice!...Would this work for a motorcycle? With more added functionality like temp, battery or Fuel?

How about RPM can that be calculated?
amandaghassaei (author) says: Jul 26, 2012. 3:17 PM
probably, I think the limiting factor would be the speed of the reed switch- there is a mechanical piece in the switch that moves back and forth to complete the circuit. At 60mph, ~1ft radius tires rotate at 25-30 rotations per second. As long as the reed switch can switch back and forth that quickly you would be able to measure speed/rpm on a motorcycle

If you want the lcd to output rpm:
add:
float rpm = 0.00; //variable rpm
and insert the line:
rpm = float(6000)/float(timer);//calculate rotations per minute
after:
mph = (56.8*float(circumference))/float(timer);
and:
rpm=0;
after:
mph=0;

and create the function:
void displayRPM(){
Serial.write(12);//clear
Serial.write("RPM=");
Serial.write(13);//start a new line
Serial.print(rpm);
Serial.write(" RPM ");
//Serial.write("0.00 RPM ");
}

and call this function in the main loop when you would like to display the RPM

and yes you could definitely expand to include temp, battery, etc, there are plenty of available pinson the arduino.
amandaghassaei (author) says: Mar 28, 2013. 11:51 PM
I realized that the line should say:
rpm = float(60000)/float(timer);//calculate rotations per minute
soshimo says: Sep 13, 2012. 9:12 AM
Why not use a Hall Effect sensor? There are no moving parts and it works off the disruption of a magnetic field. They are used in many high speed applications because of this. Those POV devices you see for bike wheels use a hall effect sensor to know when to flash the LEDs for the POV illusion.
amandaghassaei (author) says: Sep 13, 2012. 11:43 AM
hall effect sensor would work too
tesladude123 says: Aug 27, 2012. 2:26 AM
would you be able to post the whole rpm code please, i just cant get it to work.

Thanks.
amandaghassaei (author) says: Aug 27, 2012. 8:11 AM


tesladude123 says: Aug 28, 2012. 2:12 AM
Thankyou. It works perfectly.
motto20 says: Feb 20, 2013. 3:10 PM
I am trying to understand your code (which works great by the way) and am wondering about your RPM and MPH calculations. Where do the values 56.8 and 6000 come from in each calculation? Thank you.
amandaghassaei (author) says: Mar 28, 2013. 11:50 PM
to convert inches/ms to miles/hr you must multiply by:
1miles/63360inches * 1000ms/sec * 60sec/min * 60min/hr = 56.8
and yes, I think I made a mistake, it should be 60,000 to calculate rpm from rev/ms:
1000ms/sec*60sec/min = 60000
thanks for catching that.
s0700419 says: Feb 27, 2013. 10:13 AM
Hi, I have tried the code which tests the reed sensor. When the sensor and magnet are in contact the Serial Monitor outputs 1023, as expected. When they are not in contact the serial monitor outputs a range of values from 0 to 1023. Can any advise on where I have gone wrong?
David97 says: Mar 14, 2013. 11:19 PM
Maby your 10k resistor is not connected between ground and A0 properley.
amandaghassaei (author) says: Mar 28, 2013. 11:03 PM
sounds right
bobbydeep says: Feb 5, 2013. 6:37 AM
What changes in the schematic should I do mam in order to use this for a car?
amandaghassaei (author) says: Feb 6, 2013. 6:23 AM
well you'll have to use the hall sensor instead of the reed switch, how many pins does your hall sensor have, do you have a schematic?
carmolim says: Dec 5, 2012. 10:17 AM
did you take a look in my code?

https://github.com/carmolim/cycloduino
amandaghassaei (author) says: Dec 6, 2012. 10:46 AM
does it work? do you have a specific question about it?
carmolim says: Jan 27, 2013. 1:01 PM
hello.. is working... today I made the first on bike, and I found a max speed limitation... what can I do to remove this limitation?
amandaghassaei (author) says: Feb 4, 2013. 11:15 PM
what is the max speed you are seeing? btw this project looks awesome, will you post it as an instructable?
carmolim says: Feb 5, 2013. 6:07 AM
I changed the maxReedCounter to 80, now I´m getting the maximum speed of 93 kph, I think...

well... I still have a long way ahead, butI´ll probably post the complete project here... I'm glad you liked the project I'm developing in my spare time and I'm having so much fun...

thank you for your help!
bobbydeep says: Feb 2, 2013. 11:25 PM
I would like to know if this would work for a car?
That is can the reed switch be used for speeds upto 50kmph and car tyre radius of about 16 inches?
amandaghassaei (author) says: Feb 4, 2013. 10:50 PM
theoretically yes, I think your idea of using a hall effect sensor instead of a reed switch for this high frequency application is a good one.
bobbydeep says: Feb 3, 2013. 7:24 AM
Also, mam can hall effect sensors be used ? will they work with this code and will they give pulses?
amandaghassaei (author) says: Feb 4, 2013. 10:48 PM
I think hall effect sensors would work with the code, though the schematic would change a bit.
Adarsh_tronix says: Dec 16, 2012. 3:55 AM
Great Instructable.Appreciate it!
myth21 says: Nov 28, 2012. 10:38 PM
thanks i figured it out finally..
myth21 says: Nov 26, 2012. 3:19 AM
can you help me about the codes?? im not good at programming..code that can turn the led on depending on what is the measurement distance of the sensor?
myth21 says: Nov 26, 2012. 3:22 AM
http://www.youtube.com/watch?v=fZfSbN2ZwLw just like this one please?? thanks
amandaghassaei (author) says: Nov 27, 2012. 9:11 AM
start by try this code and seeing if you can output the distance with the serial monitor:
http://www.instructables.com/id/Easy-ultrasonic-4-pin-sensor-monitoring-hc-sr04/
amandaghassaei (author) says: Nov 27, 2012. 9:12 AM
here's another good link:
http://www.arduino.cc/en/Tutorial/Ping
myth21 says: Nov 27, 2012. 7:05 PM
actually i found some codes but it output the results to a piezo buzzer. and when i compile it says
"In file included from UltrasonicDemo.pde:8:
D:\arduino-1.0.2\libraries\Ultrasonic/Ultrasonic.h:11:22: error: WProgram.h: No such file or directory"

heres the code i found
//Vcc to 5 volt +
//Trig to pin 12
//Echo to pin 13
//Grd to Grd
//Piezo to pin 9
//GRD to GRD

#include "Ultrasonic.h"
Ultrasonic ultrasonic(12,13); //12,13 are pin assignements
intbuzzPin = 9; // positive connection of the piezo
int delay1 = 25;
void setup() {
Serial.begin(9600);

}

void loop()
{
Serial.print("cm :");
Serial.print(ultrasonic.Ranging(CM));
Serial.println("");
//delay(100);



if(ultrasonic.Ranging(CM) > 0 &&ultrasonic.Ranging(CM) <= 5)
{ tone(buzzPin, 100 ,100); delay(100);}
if(ultrasonic.Ranging(CM) > 5 &&ultrasonic.Ranging(CM) <= 10)
{tone(buzzPin, 100 ,100); delay(100);}
if(ultrasonic.Ranging(CM) > 10 &&ultrasonic.Ranging(CM) <= 20)
{tone(buzzPin, 15 ,100); delay(50);}
if(ultrasonic.Ranging(CM) > 20 &&ultrasonic.Ranging(CM) <= 30)
{tone(buzzPin, 14 ,100); delay(50);}
if(ultrasonic.Ranging(CM) > 30 &&ultrasonic.Ranging(CM) <= 40)
{tone(buzzPin, 13 ,100); delay(50);}

if(ultrasonic.Ranging(CM) > 40 &&ultrasonic.Ranging(CM) <= 60)
{tone(buzzPin, 12 ,100); delay(50);}
if(ultrasonic.Ranging(CM) > 60 &&ultrasonic.Ranging(CM) <= 90)
{tone(buzzPin, 11 ,100); delay(050);}
if(ultrasonic.Ranging(CM) > 90 &&ultrasonic.Ranging(CM) <= 120)
{tone(buzzPin, 10 ,100); delay(50);}
if(ultrasonic.Ranging(CM) > 120 &&ultrasonic.Ranging(CM) <= 200)
{tone(buzzPin, 9 ,100); delay(50);}
if(ultrasonic.Ranging(CM) > 120 &&ultrasonic.Ranging(CM) <= 200)
{tone(buzzPin, 8 ,150); delay(50);}
if(ultrasonic.Ranging(CM) > 200 &&ultrasonic.Ranging(CM) <= 300)
{tone(buzzPin, 9000 ,150); delay(50);}

}
i already put the files in the arduino library..but theres still error..can you help me.. thank you ..:)
amandaghassaei (author) says: Nov 27, 2012. 8:11 PM
you need to download a library called ultrasonic.h and add it to your libraries folder inside arduino
myth21 says: Nov 27, 2012. 6:56 PM
thanks.. ill try this..
carmolim says: Nov 25, 2012. 4:24 PM
Hello again,

Just wanted to say that my project is hosted here: https://github.com/carmolim/cycloduino

I would like you to take a look to see if I am following in a good way and if possible give some suggestion.

Thank you.
myth21 says: Nov 24, 2012. 2:33 AM
i used ultrasonic sonar sensor that can detect up to 3.5 meters..and i also used arduino duemilanove atmega 168.. my problem is i cant upload the code..it says avrdude stk500_getsync() not in sync resp=0x00...can u help me??
1-40 of 75Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!