กลับไปหน้ารวมไฟล์
rotary-controlled-led-row-703098-en.md

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:

  1. 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.
  2. 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.
  3. 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.

ข้อมูล Frontmatter ดั้งเดิม

title: "Rotary Controlled LED Row"
description: "Control multiple LED states using a rotary switch or potentiometer."
author: "sathyaraj00"
category: "Lights & LEDs"
tags:
  - "rotary switch"
  - "led"
  - "arduino"
views: 2362
likes: 0
price: 435
difficulty: "Intermediate"
components:
  - "1x Arduino UNO"
  - "8x LED (generic)"
  - "1x Rotary Potentiometer or Encoder"
  - "8x Resistor 220 ohm"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "..."
encryptedPayload: "..."
seoDescription: "Use a rotary control on your Arduino to intuitively cycle through lighting patterns or individual LED control."
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/rotary-controlled-led-row-703098_cover.jpg"
lang: "en"