Lesson 16 Potentiometer Module

Share for us


A potentiometer is a device which is used to vary the resistance in an electrical circuit without interrupting the circuit.

Required Components

1 * Raspberry Pi

1 * Breadboard

– 1 * Potentiometer module

– 1 * Dual-Color LED module

– 2 * 3-Pin anti-reverse cable

– Several Jumper wires

Experimental Principle

An analog potentiometer is an analog electronic component. What’s the difference between an analog one and a digital one? Simply put, a digital potentiometer refers to just two states like on/off, high/low levels, i.e. either 0 or 1, while a digital one supports analog signals like a number from 1 to 1000. The signal value changes over time instead of keeping an exact number. Analog signals include light intensity, humidity, temperature, and so on.

In this experiment, PCF8591 is used to read the analog value of the potentiometer and output the value to LED. Connect pin SIG of the potentiometer to pin AIN0 of PCF8591. Connect pin R or Pin G of the Dual-Color LED to pin AOUT of PCF8591 to observe the change of LED.

The schematic diagram of the module is as shown below:

Experimental Procedures

Step 1: Build the circuit.

Raspberry PiGPIO Extension BoardPCF8591 Module
PotentiometerGPIO Extension BoardPCF8591 Module
Dual-Color ModuleGPIO Extension BoardPCF8591 Module
G *  *

For C Users:

Step 2: Change directory. 

    cd /home/pi/SunFounder_SensorKit_for_RPi2/C/16_potentiometer/

Step 3: Compile.

    gcc potentiometer.c -lwiringPi

Step 4: Run.

    sudo ./a.out

For Python Users:

Step 2: Change directory. 

    cd /home/pi/SunFounder_SensorKit_for_RPi2/Python/

Step 3: Run.

    sudo python3 16_potentiometer.py

Turn the knob of the potentiometer, and you can see the value printed on the screen change from 0 (minimum) to 255 (maximum).