Go Down

Topic: An LED bar graph tachometer (Read 9848 times) previous topic - next topic


I want to build a simple LED bar graph tachometer. Maybe 10-12 LED's, green, yellow and red. Maybe an orange thrown in there  :D

The "redline" will only be 4500-5000 RPM.

Perhaps 1000rpm= 2 lit, 2000rpm= 3 lit, 2500rpm= 4 lit, etc.

I've been tinkering with practice code making led's blink and stay lit plus some sequencing so the hardware side won't be much trouble. Plus, I'm finding that I'm A LOT more into the BUILDING over the PROGRAMMING *sigh*  Hopefully this will change as I become more proficient (And less confused) by it...

I have an IR receiver and emitter set so I would like to start with using that for a trigger but I've ordered a couple of hall-effect sensors and magnets for the final build.

This will be my first project involving both input and output so it should be a good learning experience!

Any guidance would be most welcome!


Sounds like a fun project,
you should post your code so people can see how you are trying this so we can offer specific examples and help,
what kind of hall sensors did u order? There are ones that are ratiometric and you get an analog signal and there are more switch type ones that the output is considered digital( high or low)
for rpm you are best of with the digital because its alot faster to do a digital read than analog read and some math



Never to old to learn and I learn every day


I ordered 10 of these:


It seems that all the examples I can find seem to use serial output to read RPM.  I'm looking for a way to illuminate a bank of LED's based on RPM.

It's complicated (at least to me  :smiley-roll-blue:) because the output to the LED's will have time factored in.  Damned if I can find a suitable code example.

I'm leaning towards something like:

if input to pin (X) = 1000 times a minute ,  output to pin (Y) hi,
if input to pin (x) = 2000 times a minute , output to pin (Y) and (Z) hi
if input to pin (X) = 3000 times a minute , output to pin (Y) and (Z) and (A) hi

(This is just my crude example of the logic I believe would be necessary  :smiley-red:)

I'm sure there would be some additional coding for I/O when the motor slowed down or else it would just "hold" the lamps on.

It would be great to find some code already written that would allow me to just change some parameters for tuning.

The learning curve is pretty steep for me but it would be sweet to actually build something useful.


First start to read the hall sensor(s) value, calculate and write the output value to the serialmonitor. A challange enough to start with as newbie.
Use a simpel electro motor first.
When this works then start to work on the display of the RPM by leds.
Search the forum here for RPM projects.

Never to old to learn and I learn every day


May 13, 2012, 11:51 pm Last Edit: May 14, 2012, 01:27 am by hoff70 Reason: 1

I found this:


And managed to get it running and printed to the serial monitor. I'm getting value changes as I shade the detector. Still not sure what to do with it though. It'll probably be a few weeks before my mail order stuff comes in...

Update before bed...

I found this:


And set it up without much fuss. Now I have 1 or 0 when I break the beam. Won't a hall effect sensor work the same way?  I figure I'll start by making an LED blink or something when the beam is broken. Should be a good start point...

I managed to get this working:

Code: [Select]
IR beam demo
#define LED 2
#define BEAM 4
byte i;
void setup()
void loop()

It's pretty basic but it seems like a good start point...


Pretty basic is the best place to start
once you get the hang of the basics you can start altering examples or making your own that does exactly what you want it to, just make sure you pay attention to how things work in those examples


That is a cool project.

If I where you, I will split the project in two parts.

Part One : Code testing using a 555 , wired it into a variable frequency generator or use a frequency generator.

Convert RPM --> Frequency

For display, I will use a 2 X 74HC595 or 1 X MAX7219 or use the digital pins ( you are a bit limited ) .

Bear in mind, the coding and wirring for display will be different for each methode use.

Get that working first.

Here a pseudo code :

Code: [Select]

RPM sample  Frequency  -- > RPM

Calculate a value to be display RPM --> numbers of leds  OR

Frequency --- > numbers of leds to display

Figure first : 1 segment - led  = what is the value in RPM / Frequency

Example : 100 RPM = one segment on  - data = 00000001
               200 RPM = 2 segment on   - data = 00000011
               300 RPM = 3 segemnt on  - data = 00000111
               400 RPM = 4 segment on - data = 00001111
               the rest...

Display the leds.

Part two :

The circuit to sample the RPM and connect with the code and display circuit. 

Anyway, that is my 2 cent idea


May 14, 2012, 08:38 pm Last Edit: May 14, 2012, 09:28 pm by backbone Reason: 1
Hall sensor, mechanical switch or optical sensor will all have the same result..... 0 or 1 as take up sensor.
Like Winner said start small and understand what your doing.
Copy and paste is not always the best way to learn I found out too as newbie in this world.

Here a link to an LCD project  http://arduinoprojects101.com/arduino-rpm-counter-tachometer/

Never to old to learn and I learn every day


Hint:   The RPM will amost never be exactly 100 or 2000 RPM   If you want a "bar-graph", you can say if >= 1000 RPM (greater than OR equal to).  If you want a "dot" display, you can turn-on the LED if it's greater than 1000 AND less than 1500, etc.

I'm sure there would be some additional coding for I/O when the motor slowed down or else it would just "hold" the lamps on.
Just put your code in a loop, so that it checks & updates as fast as it can.    Or, if that makes the display too "jumpy", you can hold the loop for 10th of a second or so before looping.   If you wanted, you could hold the top LED a bit longer, or freeze it 'till you hit a "reset" button, etc.  Or, hold longer if you go over the redline, etc.


May 15, 2012, 05:31 am Last Edit: May 15, 2012, 06:53 am by hoff70 Reason: 1
Thanks for the helpful input!

I thought about rigging up a pulse generator to aid with code testing but I decided on building a test mule similar to the final deal:

Looks like a weird lathe  :smiley-roll:

It's a 12V DC motor with a slotted disc for breaking the IR beam. It's kind of hit and miss with reading the input. The serial monitor shows the occasional double 1 or zero. I'm not sure what's going on there. I'm hoping it will suffice for working out some of the details before my hall effect sensors get here. Hopefully any success I have will be applicable to the HE sensor setup.

I rigged up a pot and a mosfet to control the motor speed. I don't have a big range of speeds though...  but it looks like enough to work with for prototyping.

I have the "Programming Arduino" book so hopefully I can get something written from scratch. I'm more of a "builder-O-crap" than a computer programmer but maybe I can get something cooking.

When I was testing the IR stuff I noticed that the detector output just BARELY dropped below 2.5 volts so maybe that has something to do with my spotty triggering.


Well, I have almost all the hardware built:

I still need to put some resistors on the led's and wires from them to the pins.

Guess I need to figure out how to code it...


If you get fed up with the breadboard and want a more durable solution, what you have there is doing pretty much what a standard LED bar shift light does. They aren't terribly expensive. I know it's not as much fun, but if you're after a working solution rather than a fun project then you might want to bear that in mind.


I could buy one but I like building crap!  Here's where I am:


I'm using the UNO to vary the speed of the motor and a Propeller board is reading IR  sensor and running the LED's.  I'm still stumped on the code for getting the bar graph to work. I figure it's a start though...


I could buy one but I like building crap! 

Understood!  :)

I'm not clear what those LEDs are doing yet - have you got the frequency detection logic working yet? You don't need the LEDs working to test that, you could simply print out the values and confirm it's measuring the speed correctly.

Go Up