RPi Pico B.Tech/Diploma Beginner

Desktop Dimming Light using Raspberry Pi Pico

Desktop Dimming Light: How to dim an LED Light using Potentiometer & Raspberry Pi Pico with MicroPython Code & Circuit

  • Suitable forB.Tech/Diploma RPi Pico students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this project, we will build a Desktop Dimming Light using Raspberry Pi Pico with MicroPython Code. We will use LED and a potentiometer for this application.
Whenever we rotate the potentiometer, the brightness of the lamp is controlled. So we achieve the effect of dimming the desk lamp.
Components Required
In this guide, I used
Elecrow Raspberry Pi Pico Starter Kit
to test different Modules. You can buy the kit and perform some other operations as well. From this kit, you can use the following components.
1. Raspberry Pi Pico Board – 1
2. Potentiometer Module – 1
3. LED – 1
4. Breadboard – 1
5. Jumper Wires – 4
6. Micro-USB Cable – 1
Potentiometer
A potentiometer is a resistive element with three terminals whose resistance can be adjusted according to a certain changing law. A potentiometer usually consists of a resistive body and a movable brush. When the brush moves along the resistor body, the resistance value or voltage that has a certain relationship with the displacement is obtained at the output end.
Potentiometers can be used as both three-terminal components and two-terminal components. The latter can be regarded as a variable resistor because its function in the circuit is to obtain an output voltage that has a certain relationship with the input voltage (applied voltage), so it is called a potentiometer.
Circuit Diagram & Connection
The connection diagram for Desktop Dimming Light using Raspberry Pi Pico & potentiometer is given below.
Connect the VCC, GND & Analog Output Pin of the Potentiometer Module to the VSYS, GND & GP26 Pin of the Raspberry Pi Pico Board. Also connect the LED positive terminal to GP15 & negative to GND.
MicroPython Code/Program
Open your Thonny IDE & Copy the following code & paste it to the editor window.

from
machine
import
Pin
ADC
PWM
from
time
import
sleep
Led_pin
=

Potentiometer_pin
=

# ADC0 multiplexing pin is GP26
def
setup
(
)
:
global
LED
global
Pot_ADC
LED
=
PWM
(
Pin
(
Led_pin
)
)
LED
freq
(
2000
)
#Set the LED operating frequency to 2KHz
Pot_ADC
=
ADC
(
Potentiometer_pin
)
def
loop
(
)
:
while
True
:
(
'Potentiometer Value:'
Pot_ADC
read_u16
(
)
)
Value
=
Pot_ADC
read_u16
(
)
LED
duty_u16
(
Value
)
sleep
(
0.2
)
if
__name__
==
'__main__'
:
setup
(
)
loop
(
)
Now you can run this code to test the working of the circuit. Rotate the potentiometer to control the brightness of the lamp to achieve the effect of dimming the desk lamp.

Technologies used

Raspberry PiBLEPythonPWMADCMicroPython

Hardware components

  • Raspberry Pi

Software & tools

  • Thonny
  • MicroPython

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.