#Set minimum value?
12 messages · Page 1 of 1 (latest)
You could do something a little heavy handedly.
void updateSliderValues() {
for (int i = 0; i < NUM_SLIDERS; i++) {
analogSliderValues[i] = analogRead(analogInputs[i]);
if (analogSliderValues[i] < 32) {
analogSliderValues[i] = 0;
}
}
}
If the read value is 31 or lower, it'll just clamp it at 0
I'm having a similiar issue, but my sound levels are hitting 0 with about 10% left on the pot's slider. Any way I can change the values to make the bottom of the slider equal 0?
i had the same thing how manny sliders do you have and to what voltage are they connected for me switching from 5 to 3.3 fixed it
^^?
Thanks I'll take a look when I get home
2 circular pots, 5v, it's most likely a bad pot, I'll try 3.3v if the other method doesn't work
The other option you could do is to map the values.
Let's say you've got some kinda dodgy pots and you only ever get readings on your serial interface between say... 35 - 1012...
You could change this line:
analogSliderValues[i] = analogRead(analogInputs[i]); to analogSliderValues[i] = map(analogRead(analogInputs[i]), 35, 1012, 0, 1023);
What this does is map values between 35 - 1012 and then spread them out evenly across 0 - 1023.
map(value, minFrom, maxFrom, minTo, maxTo)
So I got home and the pot is now working properly lol, but this is still really useful, if it happens again I can use this 🙂
thanks again