Just thinking more about this, I am not sure I have my sketch correct for the Hall Sensor?
With the "pulseIn" function I am reading High to Low so I am reading the On time of the pulse.
If I am correct I think the Hall Sensor will have a pulse of equal On time no matter what the frequency is?
So I have to read from Low to High & read the varying Off time, do I have this correct?
No. Frequency is most generally determined by measuring the time from one
rising edge to the next. (Using the descending edges is also possible, of course, - oscilloscopes have that feature as part of the "Triggering" options).
I am assuming that the Hall effect is being triggered by a rotating magnet. Thus the pulse width AND frequency will change with varying RPM: Low RPM =
longer pulse width AND
lower frequency, with the opposite being true as RPM increases.
I am also assuming that, with a single Hall device, the time between pulses will almost invariably be significantly greater that the timing of the pulse itself.
So, the obvious signal of choice for a reasonable control number for the "W" of PWM output would be the
pulse width (High to Low) number to allow for this data to control a subsequent PWM pulse from the Arduino.
If you want the Arduino output pulse width to
increase with an
increasing RPM of the triggering magnet, you'll need to reverse the order of your mapping conversion from high to low.
And, of course, the PWM duration will remain stable between Hall triggers.
Here's an interesting alternative:
https://www.pjrc.com/teensy/td_libs_FreqMeasure.html (it measures