#Set minimum value?

12 messages · Page 1 of 1 (latest)

deft sand
#

One of my pots doesn't go to 0, it has a minimum value of 32 on the serial monitor.
Any way to get deej/the arduino to register it as a 0 value?

finite mantle
#

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

golden verge
#

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?

obtuse oar
deft sand
deft sand
finite mantle
#

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)

deft sand
#

thanks again