Introduction: Building a Cheap Two-digit Display for Arduino

I usually get ideas when I am taking a shower. It must have something to do with putting the brain into a very calm environment. So once while I was taking a shower I thought about an Arduino project I had done a while ago and how complicated it was to connect two 7-segment LED displays to 14 of the output ports (I hate soldering). It takes away most of the ports and in practical use the cables break occasionally resulting in a lot of maintenance. There should be a better way to do this.

Step 1: Design

The evening before I had read about the built-in timers of the Arduino and how to program them. Then suddenly it sparked into my mind. How about using this timer to trigger a digital bicycle speedometer and use its display to show the numbers? The Arduino would simulate the magnet fixed to the bike wheel closing the sensor circuit with every revolution. Depending on the timer parameters and the configured wheel size (in the speedometer) this would lead to a specific speed displayed on the speedometer. My application doesn't need to update the digits every 20 milliseconds so I could live with the display needing some time to adjust to changed timer settings.

Step 2: Implementation

The next day I bought a cheap speedometer for about 7,-€. I clipped off the sensor cable and tested the functionality by shorting the lines repeatedly. That worked fine. Now I had to simulate the shortening by electronic means. That's where an optocoupler comes into play. I used one to isolate the output of the timer from the sensor cables. A simple program for the Arduino proved that it's working. In the circuit below I had to use the red LED as a surrogate for the sensor cable. Also the output #13 was used to prove that the circuit is working. In reality you have to connect it to the output that is triggered by the timer (e. g. #9).

Step 3: Maths and Tries

Now to get some sensible results you need to do some maths. But I found out that all my calculations still needed some practical experiments before I could see the results I wanted to (that's the reason for the "correction factor" in the program below :-)).

One thing I had to learn is that a millisecond has a rather big influence on the measured speed. So if you want to show bigger numbers (>50) on your new display you have to push as many milliseconds into the wheel's revolution as possible. That means you should configure the Speedometer with the biggest wheel circumference possible.

I chose to set the circumference to 3600 mm because this makes calculations a lot simpler. Here is the program that displays numbers from 30 to 60 changing every 2 seconds:

#include <TimerOne.h><br>// set constants
const long circumference = 3600; // circumference of the tire in millimeters set in the bike speedometer
<br>// set global variables
long period = 214000;
int duty = 1;
<br>void setup() {
  // put your setup code here, to run once:
  Timer1.initialize(period);         // initialize timer1, and set a period
  Timer1.pwm(10, duty);              // setup pwm on pin 9, duty cycle
<br>void loop() {
  // display numbers from 30 to 60 (approximately :-))
  for (int i = 30; i < 60; i++) {
    setBeatValue (i);
<br>void setBeatValue(int bpm) {
  period = circumference * 3600 / bpm - 1150 ; // period in microseconds minus correction factor


You can see this program execute in the video I attached to this step.

Circuits Contest 2016

Participated in the
Circuits Contest 2016