Arduino Variable Resistor (Potentiometer) Control

Introduction

A variable resistor (potentiometer) allows you to control voltage levels manually. In this project, we use a potentiometer to control LED brightness using Arduino PWM.


Components Required

  • Arduino Uno R3
  • Potentiometer (10K)
  • LED
  • 220Ω resistor
  • Breadboard

Circuit

Potentiometer connections:

  • Left pin → 5V
  • Right pin → GND
  • Middle pin → A0

LED connections:

  • LED positive → Pin 9
  • LED negative → 220Ω resistor → GND

Arduino Code

int potPin = A0;
int ledPin = 9;void setup() {
pinMode(ledPin, OUTPUT);
}void loop() {
int value = analogRead(potPin);
int brightness = map(value, 0, 1023, 0, 255); analogWrite(ledPin, brightness);
}

How It Works

  • analogRead() reads the potentiometer value
  • The value ranges from 0–1023
  • map() converts it to 0–255
  • analogWrite() controls LED brightness using PWM

Conclusion

This project demonstrates:

  • Analog input reading
  • PWM output control
  • Variable brightness adjustment

It is a fundamental Arduino project used in motor control, dimmers, and sensor systems.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top