It is simple to create a speedometer/tachometer for nearly any man-powered vehicle with an Arduino. For my skateboard, I designed one that used a tiny magnet to measure rotations and an LCD display screen. This Instructable will walk you through the process step by step.
1) A vehicle propelled by humans (I will be using a skateboard)
2) An Arduino board
3) An Arduino protection box made of plastic (pictured)
4) A little magnet (mine is around 0.2 inches tall and 1/4 inch in diameter).
5) A magnetic relay switch is a device that allows you to control the flow of electricity
6) A 9V battery, as well as an adapter to connect it to the Arduino plug
7) A tiny LCD display (16 x 2 character display)
8) Resistors of 10K and 47 Ohm
9) The Wires
10) Solder and a soldering iron
11) Adhesive such as gorilla glue, super glue, crazy glue, or something similar
12) Potentiometer (10K)
The first step is to attach the magnet to the wheel.
I started by embedding the little magnet in my rubber skateboard wheel. On the inside of one of my back wheels, towards the edge, I drilled a small hole (1/4″ diameter to fit the magnet snuggly). I then put some gorilla glue in the hole and inserted the magnet such that half of the magnet’s height was buried in the wheel and the other half protruded from the wheel. When the magnetic relay switch is near the spinning magnet later, this magnet will allow the relay switch to count the wheel’s rotations.
The Electronics are the next step.
The next step is to make sure that all of the electronics are working properly. You can see the circuit schematic here. The red connections link to the Arduino’s +5V pin, while the green connections connect to the ground pin. To prevent the circuit from shorting out, solder (and maybe heat shrink) your connecting points. This will also prevent the connectors (and hence the speedometer) from failing when the device is in operation. It’s possible that you’ll want to hook everything up on a different board from the Arduino. To limit the connections into the real Arduino pins, you may wire the pot, ground, and +5V components to this board.
This will make your electronics more organised and manageable. It’s also crucial to think about where you’ll put the LCD before you start wiring it all together. It may be essential to take measures to guarantee that this connection is available once the LCD is set up, depending on where you choose to install your display. For example, because the LCD was installed in my board and the wire ran through a small hole, I had to first install the LCD and then pass the wiring through the hole to the LCD before connecting everything.
The Arduino Code is the third step.
int val;
long last=0;
int stat=LOW;
int stat2;
int contar=0;
int displayrpm;
int sens=75; // this value indicates the limit reading between dark and light,
// it has to be tested as it may change acording on the
// distance the leds are placed.
int nPalas=1; // the number of blades of the propeller
int milisegundos=500; // the time it takes each reading
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
lcd.begin(16,2);
}
void loop()
{
val=analogRead(0);
if(val<sens)
stat=LOW;
else
stat=HIGH;
digitalWrite(13,stat); //as iR light is invisible for us, the led on pin 13
//indicate the state of the circuit.
if(stat2!=stat){ //counts when the state change, thats from (dark to light) or
//from (light to dark), remmember that IR light is invisible for us.
contar++;
stat2=stat;
}
if(millis()‐last>=milisegundos){
double rps=((double)contar/nPalas)/2.0*1000.0/milisegundos;
double rpm=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
displayrpm=rpm;
Serial.print((contar/2.0));Serial.print(" RPS ");Serial.print(rps);
Serial.print(" RPM");Serial.print(rpm);Serial.print(" VAL ");Serial.println(val);
contar=0;
last=millis();
Serial.print(" MPH ");
Serial.print(rpm*0.0080622311);
LCDPrint ();
}
}
void LCDPrint ()
{
lcd.clear ();
lcd.setCursor (0,0);
lcd.print("MPH");
lcd.setCursor (0,1);
lcd.print(displayrpm*0.0080622311 );
lcd.setCursor (8,0);
lcd.print("RPM");
lcd.setCursor (8,1);
lcd.print(displayrpm);
return;
}
The line “Serial.print(rpm*0.0080622311)” is quite noteworthy. This line will be unique to each individual. This line of code converts the RPM value read by the relay and Arduino into MPH. To do so, you’ll need:
rpm(circumference of your wheel in inches)(60 min/hr)*(1/63,360 miles/inches)=speed in MPH
Once you’ve figured out what constant the RPM must be multiplied by to convert to MPH, simply replace the 0.0080622311 in the code.
When the Arduino is hooked in, the gadget should correctly show MPH and RPM on the LCD display if the electronics are properly linked up and the Arduino is programmed with the supplied code and suitable MPH arithmetic . When you spin the wheel while holding the magnetic relay switch near the magnet, the LCD should display the corresponding MPH and RPM for the wheel’s revolution.
Step 4: Keeping the Electronics Safe
After that, you’ll want to put all of your electronics in the Arduino case made of plastic. This enclosure has plenty of room for the Aruino and the 9V, as well as some wiring. This is the interior of my protective box. Keeping the devices in this box will not only keep them together in one area, but it will also ensure that they are safe when travelling. You may need to cut small holes in the side of the plastic box so that cables needing to exit the box may do so without being squeezed by the case’s top cover. I also recommend sealing the box shut so you don’t have to worry about it opening and spilling all of your devices while riding.
You should have a plastic box with the electronics and a 9V battery after completing this step. Two wires should be joined to the magnetic relay switch, and 12 wires should be hooked to the LCD screen (ideally neatly grouped together). The LCD should be lighted and counting the RPM and corresponding MPH anytime the small revolving wheel magnet is sufficiently enough to the relay switch when the Arduino in the plastic enclosure is plugged in.
Step 5: Assembling the Parts
I installed the plastic box on the underneath of my skateboard, near the front truck (pictured). The relay switch cables travelled down the centre of the board to the rear truck’s wheel, where the little magnet was embedded. By zip tying the relay switch to the vehicle, I was able to keep it close to the steering wheel. The 12 wires that connect the LCD to the rest of the board leave the plastic box and go up to a tiny hole on the board’s nose. The hole goes into a small chamber where the LCD is embedded on top of my board (and protected by a thin acrylic sheet).
“Keep the child inside you alive. Motivate others for it, Afterall sharing is caring. Right?”
– Helping Hands.
I loved it 😉