Potentiometer with Arduino

Potentiometer.

In this article, we will guide you to discover exactly what a potentiometer is. We will explore its meaning, how it works in the real world, the different types you can find, and, to give it a practical touch, we will show you some of the many ways in which these devices are used.

What is a Potentiometer?

A potentiometer is an electronic device used to vary electrical resistance in a circuit. Typically, it consists of a three-terminal resistor, where the resistance value between two of the terminals can be adjusted manually. The third terminal is connected to a movable slider that can slide along the resistor. By rotating or sliding the potentiometer, the resistance between the slider terminal and one end of the resistor changes, allowing control of the current flow in the connected circuit. Potentiometers can be linear or rotary. Regarding the relationship between position and resistance, we find linear, logarithmic, or exponential potentiometers.

Parts of a Potentiometer

Diagram of a potentiometer.

The parts of a potentiometer are as follows:

  • Body: It is the main structure of the potentiometer that contains all the other parts and provides the base for mounting and manipulation.

  • Shaft: It is the part that is rotated or slid to adjust the electrical resistance of the potentiometer.

  • Fixed terminals: These are the ends of the resistor that remain connected to the electrical circuit and do not move.

  • Moving terminal or slider: It is the point of contact that moves along the resistor and allows adjusting the value of the electrical resistance.

  • Resistance track: It is the conductive track that varies in length and is connected between the fixed and moving terminals. This resistance is adjusted to control the flow of electrical current.

  • Resistive material: It is the material composing the resistance that determines its ability to regulate the flow of current. It can be of different types, such as carbon, cermet, or metal film.

  • Protective cover: It is an external layer that covers the resistance and protects its mechanical and electrical integrity.

Assembly

The assembly of this circuit in Arduino is very simple, requiring only power supply and one analog pin for reading the voltage values ​​in the variable resistance.

Assembly of a potentiometer with Arduino.

Code to use a potentiometer with Arduino

In the code, we only need to read the analog pin using the analogRead() function.

 1// Arduino example to use a potentiometer
 2// More information: https://www.3dpellet.com
 3
 4// We define the analog input
 5#define analogPin A0
 6
 7void setup() {
 8  Serial.begin(9600);
 9}
10
11void loop() {
12  // The analog pin is read
13  int value = analogRead(analogPin);
14
15  // The read values are printed
16  Serial.print("\nValor X: ");
17  Serial.print(value);
18  
19  delay(1000);
20}

What this small program does is read the value of the analog input A0 and then print it on the serial monitor of the Arduino IDE. As you can see, it is very easy to use and incorporate into our projects as a control interface.

Uses of Potentiometers

Potentiometers have a wide range of applications in various areas. Here are some common use cases:

  • Volume control in audio equipment: Potentiometers are used to adjust the volume of audio equipment such as amplifiers, radios, and sound systems.

  • Brightness control in displays and light panels: Potentiometers are employed to regulate the brightness of displays, LED panels, and other devices that require brightness adjustment.

  • Speed control in electric motors: In some cases, potentiometers are used to control the speed of electric motors, such as in fans, power tools, and motorized toys.

  • Pitch adjustment in musical instruments: In electric guitars and other musical instruments, potentiometers are used to adjust the pitch and tone of the sound.

  • Temperature control in heating and cooling systems: Potentiometers can be used in thermostats to adjust the desired temperature in heating, ventilation, and air conditioning systems.

  • Brightness control in lamps and lighting devices: Potentiometers are employed to adjust the light intensity in lamps and lighting devices, such as desk lamps, ambient lights, and floor lamps.

  • Gain adjustment in electronic circuits: In electronic circuits, potentiometers are used to adjust the signal gain in amplifiers and audio and video control circuits.

These are just a few examples of the numerous use cases of potentiometers in various electronic and electrical applications. Their versatility and adjustability make them fundamental components in a wide variety of devices and systems.