LED bargraph with max7219 based on rpm/speed input
chetw77cruiser
Posts: 12
Well, this looks to be my first post here, so I will start off easy. I have been working some on a digital instrument sluster and I have a programmers cramp. I want to be able to input a max rpm variable, divide that by 40(number of leds attached to a max7219) and lite individual leds based on rpm*1, rpm*2, etc. mainly in that order. I am trying the if-else if with little success. I am stumped. I want to be able to enter anyrhing from 4000 rpm to 8000 rpm and be able to divide that between 40 leds, maybe more if needed. Would the lookup/lookdown be a better way?
If this is to little information, let me know and I will fill in the blanks.
Chet W.
If this is to little information, let me know and I will fill in the blanks.
Chet W.
Comments
(rpm - rpmmin) / (rpmmax - rpmmin) = n / number_of_LEDs
with numbers:
(rpm - 4000) / (8000 - 4000) = n / 40
or
n = (rpm - 4000) / 100
For rpm = 4000 this gives you n = 0 (no LED), rpm = 8000 will result in n = 40 (all LEDs). HTH
I am not sure how to code that and have it output to the max7219. I forgot to mention that I am using spin and I only have a basic knowledge of programing in general, mainly from 15 years ago using qbasic. I am using this project as a learing experience.
How do you get the RPM into your system? Also, if your min/max values are different simply substitute them in the equation.