Skip to content

Project 2.11.2: Potentiometer LED Dimmer

Description This project uses a potentiometer to control the brightness of an LED through PWM, creating a smooth dimming effect.
Use case This project can be used in automation systems, interactive installations, and embedded control applications.

Components (Things You will need)

Arduino Uno Arduino USB Cable Breadboard Jumper Wires Potentiometer LED

Building the circuit

Things Needed:

  • Arduino Uno = 1
  • Arduino USB cable = 1
  • Potentiometer = 1
  • LED = 1
  • Breadboard = 1
  • Jumper wires

Mounting the component on the breadboard

Step 1: Place the Potentiometer and the LED on the breadboard.

Components on breadboard

NB: Make sure all components are securely placed on the breadboard with correct orientation.

WIRING THE CIRCUIT

Step 2: Connect one outer pin of the Potentiometer to GND pin on the Arduino Uno using male-to-male jumper wires.

Wiring diagram

Step 3: Connect the other outer pin of the Potentiometer to 5V pin on the Arduino Uno using male-to-male jumper wires.

Wiring diagram

Step 4: Connect the middle pin of the Potentiometer to Analog pin A0 on the Arduino Uno using male-to-male jumper wires.

Wiring diagram

Step 5:Connect the anode (long leg) of the LED to one end of a 220 Ω resistor.

Wiring diagram

Step 6: Connect the other end of the resistor to Digital Pin 9 on the Arduino.

Wiring diagram

Step 7: Connect the cathode (short leg) of the LED to GND on the Arduino.

Wiring diagram

Make sure to connect the Arduino USB cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Type the following code in your Arduino IDE: const int potPin = A0;, const int soundPin = A0;, const int ledPin = 9;, int potValue = 0;, int brightness = 0; as shown in the image below.

Wiring diagram

Step 3: Type the following code in your Arduino IDE: pinMode(ledPin, OUTPUT);, Serial.begin(9600); as shown in the image below.

Wiring diagram

Step 4: Type the following code in your Arduino IDE inside the void setup() pinMode(ledPin, OUTPUT);, Serial.begin(9600); as shown in the image below.

Wiring diagram

Step 5: Type the following code in your Arduino IDE inside the void loop() potValue = analogRead(potPin);, brightness = map(potValue, 0, 1023, 0, 255);, analogWrite(ledPin, brightness);, Serial.print("Potentiometer: ");, Serial.print(potValue);, Serial.print(" Brightness: ");, Serial.println(brightness);, delay(10); as shown in the image below.

Wiring diagram

Step 6: Save your code. See the Getting Started section

Step 7: Select the Arduino board and port. See the Getting Started section

Step 8: Upload your code.

CONCLUSION

This project helps learners understand how to combine multiple components with Arduino to create more complex interactive systems and automation solutions.