This project allows you to control an LED’s brightness by rotating an encoder knob.
The system uses a rotary encoder to adjust the brightness level of an LED through pulse-width modulation (PWM). When you turn the encoder clockwise, the LED gets brighter; when you turn it counter-clockwise, the LED dims. The Arduino continuously monitors the encoder position and maps its value to a brightness level between 0 (off) and 255 (maximum brightness).
Parts List
- Arduino board
- Rotary encoder
- LED
- 220Ω resistor (for LED protection)
- Jumper wires
- Breadboard
Assembly Instructions
- Connect the rotary encoder:
- Connect the encoder’s first pin to digital pin 2 on the Arduino
- Connect the encoder’s second pin to digital pin 3 on the Arduino
- Connect the encoder’s ground pin to GND on the Arduino
- Connect the LED:
- Connect the LED’s anode (longer leg) to pin 9 on the Arduino through a 220Ω resistor
- Connect the LED’s cathode (shorter leg) to GND on the Arduino