Connecting a Potentiometer to Arduino: Code and Wiring Diagram

In this article, I will show you how to connect a potentiometer to Arduino by controlling an LED.

A potentiometer is simply a varying resistor. This means you can amplify or reduce the amount of electricity passing through the circuit.

Today, I will show you the ropes in wiring a potentiometer to integrate in your next project.

Watch the video here to see the full demonstration of Connecting a Potentiometer to Arduino: Code and Wiring Diagram

Connecting a Potentiometer to Arduino: Steps in Creating the Device

Here are the steps in creating RFID Door Lock Arduino Project with Data Logging in Python.

  1. Gathering the Components

    The first thing to do is to collect the hardware components for the Arduino device.
    Arduino Uno
    Potentiometer
    LED

  2. Connecting the Components

    Connect the components to the Arduino Uno. Please refer to the wiring diagram below.

  3. Coding the Arduino

    Third step is about coding the Arduino device.

  4. Upload the Sketch

    Final step is uploading the sketch to the Arduino.

Step 1: Gathering the Components

To start off, this project will have two parts: the Arduino Device and the Program. First thing to do is to collect the hardware components and make the device. To do that, you will be needing the following:

QuantityComponents
1Arduino Uno
1Potentiometer
1LED

Arduino UNO

Arduino Uno
Arduino Uno

You will be using Arduino Uno for this project. It is an easy to use microprocessor board. Arduino Uno is suitable for any projects and is the cheapest and widely used microprocessor board in the Arduino family. This is great for all kinds of IoT projects.

Potentiometer

potentiometer
Potentiometer

The image above is a potentiometer. It has 3 pins – VCC, the input pin for the Arduino, and the GND. Some type needs to be soldered while some you can easily use on the breadboard.

Take note, if you want to give more power by turning the knob to the right, attach the 5V wire to the third pin.

LED

We will use a LED to demonstrate the potentiometer’s capability. The LED’s brightness will be controlled using the potentiometer.

Other Components

Other components (but not required) is a resistor and a LCD. You can use a resistor for the LED and display the values on the LCD. Don’t worry if you don’t have an LCD or resistor because the project will work just fine without them.

Step 2: Connecting the Arduino Components

Potentiometer controlled LD Wiring diagram
Potentiometer controlled LD Wiring diagram

Now you are ready to connect the components to the Arduino Uno. Attach the middle pin of the potentiometer to the Analog Pin 0 of the Arduino and the longer leg of the LED to Digital Pin 9 or any Digital Pin that supports pulse-width modulation. This is indicated by a wavy dash beside the pin number.

Step 3: The Arduino Code

Now the wiring is done, all you need to do is copy the code and upload it to the Arduino. Simply remove the LCD codes if you don’t have any.

Now upload the sketch to the Arduino.

Step 4: Test Run

After you successfully upload the sketch, turn the knob clockwise. The LED will slowly light up as the input increases.

Potentiometer Arduino project actual testing
Potentiometer Arduino project actual testing

Conclusion

So there you have it! Connecting a Potentiometer to Arduino. This project is intimidating at first but you will see that it is fairly easy to do. You can combine this to other Arduino projects and build an awesome system!

Download

Click the button below to download the source code.

Inquiries

Feel free to write your questions about this project at the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.