Project Overview
The Rotary Controlled LED Row project provides a hands-on way to explore analog input combined with digital output multiplexing. By turning a single rotary dial (potentiometer), you can light up different LEDs in a row, creating a "VU meter" effect or a manual selection tool.
Hardware Infrastructure
- Analog Input (Potentiometer): A 10k-ohm potentiometer is connected between 5V and GND with its center pin (wiper) wired to Analog Pin A0.
- Digital Outputs (LED Row): A row of 8-10 LEDs is connected across the Arduino's digital pins (e.g., Pins 2 through 9). Each LED has a current-limiting resistor to ensure safe operation.
Data Translation: From Analog to Digital
The Arduino's Analog-to-Digital Converter (ADC) converts the potentiometer's voltage into a digital value from 0 to 1023. We then "map" this range to the number of LEDs in our row:
int val = analogRead(A0);
int numLedsLit = map(val, 0, 1023, 0, 8);
Display Functionality
The code iterates through the LED pins. If a pin's index is less than numLedsLit, the LED is turned HIGH; otherwise, it remains LOW. This creates a smooth "bar" of light that grows or shrinks as the dial is turned.
Creative Customization
To make the display more professional, you could:
- Pulse Width Modulation (PWM): Use PWM to make the "last" LED in the bar fade in and out proportionally to the dial's position, providing higher resolution than the number of LEDs allows.
- Reverse Action: Modify the code so that the dial picks a single LED to light up, rather than filling a bar, turning it into a selector switch.
- Audio Input: Connect the output of an audio amplifier to the analog pin instead of a potentiometer to create a real-time Audio Spectrum Visualizer.
Practical Use
This type of interface is commonly found on volume knobs, battery level indicators, and home appliance controls.