#Change 0-1023 to 0-100
4 messages · Page 1 of 1 (latest)
Hi @pearl kettle
I have noticed on my esp32 that the voltage readout from the ADC can sometimes output values like -1 or 1024 (I didn’t figure out why) and it seemed to me that the deej app doesn’t cover values outside the 0-1023 range? So I just created an explicitly condition in Arduino FW code to only send values from 0-1023 and it fixed the “volume stuck” issues for me.
Not 100% sure why you want this because Deej desktop app needs to receive 0 - 1023, but feel free to experiment.
What you're after is something like this:
scaledVal = map(val, fromLow, fromHigh, toLow, toHigh);
scaledVal = map(val, 0, 1023, 0, 100);
If you're having the data go out of range, you can always constrain it
constrainedVal = constrain(val, min, max);
constrainedVal = constrain(val, 0, 1023);