I'm using several ACS712-based 5A current sensors. They're non-polar and so (I gather) the output is biased to Vcc/2 to allow a swing in either direction. The sensor outputs +/- 185mV/A, plus the bias.
The example sketch I've seen does a computation like
amps = ((analogRead(A0) * 5.0) / 1023) - 2.5 (where 2.5v is the bias).
In my case the actual current value and polarity aren't important, just the presence of current. Is there anything untoward about doing this instead?
boolean isCurrent = (abs(analogRead(A0) - 512) > thresholdValue);
This avoids floating point (unless
abs() forces it?) and an ADC count of 512 should be equivalent to a bias of Vcc/2. The threshold just cores out some noise / jitter / drift. Seem OK? Can anyone suggest a better approach?