Arduino Tutorial 08: Dim LED with Potentiometer

Hello!!!! & welcome guys in this tutorial we are going to create a dimmable led circuit(Dim LED with Potentiometer) .

So, let’s start


  • 1 x Arduino Uno R3 Board
  • 1 x Laptop or pc
  • 1 x Bread board full size
  • 1 x POT(Variable Resister)
  • 1 x LED(5 mm or 3 mm )
  • 1 x USB cable
  • Jumper wires

Connection Diagram


Source Code 01

int potPin= A0; //Declare potPin to be analog pin A0
int LEDPin= 9; // Declare LEDPin to be arduino pin 9
int readValue; // Use this variable to read Potentiometer
int writeValue; // Use this variable for writing to LED
void setup() {
 pinMode(potPin, INPUT); //set potPin to be an input
 pinMode(LEDPin, OUTPUT); //set LEDPin to be an OUTPUT
 Serial.begin(9600); // turn on Serial Port
void loop() {
 readValue = analogRead(potPin); //Read the voltage on the Potentiometer
 writeValue = (255./1023.) * readValue; //Calculate Write Value for LED
 analogWrite(LEDPin, writeValue); //Write to the LED
 Serial.print("You are writing a value of "); //for debugging print your values



!!!!!!!!!!!!!!!!!!!!Congratulations Enjoy!!!!!!!!!!!!!!!!!! 

Hope you guys like our tutorial series. We will see you in the next tutorial with new programming and electronics concepts.

comments powered by Disqus

how can we help you?

Please leave your contact details, Our customer relationship manager will assist you.

get in contact
Be the Campus Ambassador of ELAN IIT Hyderabad!