Multi-Function Shield

Multi-Function Shield: Potentiometer

Read the knob, then use a threshold to switch the LEDs.

An analog input on the shield

The blue potentiometer is on analog pin A0. Turning it changes the resistance, and analogRead(A0) returns a value from 0 to 1023.

The first sketch just prints the reading to the Serial Monitor at 9600 baud so you can watch it change as you turn the knob with a screwdriver. The second adds a threshold: below 400 all four LEDs come on, above it they go off (remember the LEDs are active-low).

A threshold like this is how you turn one knob into a mode selector: one range for a clock, another for a stopwatch, another for a timer.

1. Print the potentiometer value
2. Threshold switches the LEDs