Control a set of 5 LEDs with a thumbwheel potentiometer?

Hello,

Newbie here. :-[

I would like to control a set of 5 LEDs with a thumbwheel potentiometer (Thumbwheel Potentiometer - 10k Ohm, Linear - COM-11173 - SparkFun Electronics) or something similar. As the wheel is turned, I would like each of the five LEDs to light up based on the position of the wheel (like turning up the volume) until all five are lit.

They way my project is being built, I need to control the LEDs with my thumb only, similar to the volume control on an old walkman. Would a thumbwheel potentiometer be a good choice?

If yes, could someone point me to a tutorial for the type of code that would be necessary?

Any guidance would be greatly appreciated :slight_smile:

Sure, you can do that! The style of the potentiometer is up to you. (The value of 10K is fine.)

The [u]Analog Read Serial[/u] shows you how to read the voltage from a pot and send the results to the Serial Monitor.

Then, you just need 5 [u]if-statements[/u] to turn-on each LED when the ADC reading is above some threshold. For example, you can turn-on the 1st LED if the reading is greater than 200, and turn-on the 2nd LED if the reading is greater than 400, etc.

The two most important concepts in programming are conditional execution (if-statements, etc.) and loops (doing things over and over, usually until some condition is reached).

I'd recommend you start with the Analog Read Serial example, and add an if-statement to turn-on the Arduino's pin-13 LED whenever the reading is above half (above about 512). Once you've got that figured-out, you should be able to add the additional LEDs and associated if-statements.

I can do that! Thanks for taking the time to respond :slight_smile: