Using potentiometer for values

If I wanted to let the user define a value, lets say n of times an LED will blink, is a potentiometer good for this?

My thought is I can identify the output of the pot and do a little bit of math to translate the reading into seconds. My hesitation is the accuracy of that pot's output, if there are small variances in voltage.

This an OK way of taking input from the user.

If I wanted to let the user define a value, lets say n of times an LED will blink, is a potentiometer good for this?

You can make that work, but it's generally not a "good way" to do it.

My hesitation is the accuracy of that pot's output, if there are small variances in voltage.

Yes. That's the problem... You can look for a range of ADC values... i.e. if ADC value is greater than 100 and ADC is less than 200 do something. If ADC value is greater or equal to 200 but less than 300, do something else.

And, it's generally not "user friendly" to have an analog (continuously variable) control to control something that's actually digital.

It's generally better to use a multi-position rotary switch, or multiple push-buttons, or "up" and "down" buttons (like how you set a digital clock) or one button that cycles-through all of the options, or a keypad, etc.

...I said "generally" a couple of times because there are exceptions. :wink: It's your project and you get to decide what's logical.

Or if you don't need perfect accuracy, you could make the blink speed variable and increase the blink rate as you turn the pot clockwise, etc. (In this case, the user can see how fast the LED is blinking and adjust the pot accordingly.)

DVDdoug:
You can make that work, but it's generally not a "good way" to do it.
Yes. That's the problem... You can look for a range of ADC values... i.e. if ADC value is greater than 100 and ADC is less than 200 do something. If ADC value is greater or equal to 200 but less than 300, do something else.

And, it's generally not "user friendly" to have an analog (continuously variable) control to control something that's actually digital.

It's generally better to use a multi-position rotary switch, or multiple push-buttons, or "up" and "down" buttons (like how you set a digital clock) or one button that cycles-through all of the options, or a keypad, etc.

...I said "generally" a couple of times because there are exceptions. :wink: It's your project and you get to decide what's logical.

Or if you don't need perfect accuracy, you could make the blink speed variable and increase the blink rate as you turn the pot clockwise, etc. (In this case, the user can see how fast the LED is blinking and adjust the pot accordingly.)

I like the blinking LED idea. I actually have several functions the user will need to edit. So my initial thought is to have 1 labeled LED represent each function. The user can toggle through to the desired function (represented by the adjacent LED being illuminated), initialize an edit mode, tap the button to the desired value, exit edit mode. Maybe the LED could blink feedback to the number assigned which is usually < 10.

I could then store those values in EEPROM.

Thoughts?

I could then store those values in EEPROM.

Yes.

Why is it a bad idea to use a pot for this? It's fine! I would only use some kind of hysteresis. In code it would look something like

int getNumber(int min, int max){
  static int readLast;
  int readNow;
  
  readNow = analogRead([the pin]);
  
  //hysteresis of 5, alter if needed
  if((readNow - readLast) > 5 || (readLast - readNow) > 5){
    readLast = readNow;
  }
  
  //Actual mapping, 0 and 1023 are the extremes of the adc, can be altered if the pot doesn't reach the extremes
  return map(readLast, 0, 1023, min, max);
}

Why is it a bad idea to use a pot for this?

Lack of feedback and positive control, it is just not a very satisfactory form of user feedback. It sounds great in theory but sucks when you try it.
Any way try it and see for your self.

I did, and as long as you don't expect to many values an have a hysteresis, it's fine.

Most button inputs are wost than this because of lack of debounce etc. And feedback? There is non! And it doesn't matter if you use buttons or a pot.

Biggest con? It's relative...

As someone said... it depends on what your application is.

To vary the frequency of a winking LED, fine.

To "set" the temperature of a thermostat: Near hopeless.

It's all to do with whether you need the input to be precise and stable. If "more up", "more down", will "do"... potentiometer works. But if "up by 5", "down by 10", or "set to 152" is the sort of thing you want... look elsewhere. Button debouncing is often... usually?... necessary, and a nuisance, but a relatively minor nuisance in general, and hugely less of a nuisance vs making a pot work for, say, setting a thermostat. Learning to debounce is also a general skill that you will make use of repeatedly. Might as well get it over with.