100751 Views
79190 Views
45286 Views
43314 Views
39973 Views
33349 Views
NextCloud
Buddy Jr.
Robot Arms
TherePi - Music Making with a Raspberry Pi
Motion Controlled Arm
Electric Trombone
Building a Robot Arm with Raspberry Pi and PCA9685
Building User Authentication for Static Sites with FastAPI
Mastering Pydantic for Robust Data Validation
Mastering Markdown for Documentation with Jekyll
Introduction to Rust
OctaPi
KevsRobots Learning Platform
50% Percent Complete
By Kevin McAleer, 2 Minutes
Welcome to Lesson 9 of the Raspberry Pi Pico with MicroPython - GPIO Mastery course. In this lesson, we will learn how to use potentiometers with the Raspberry Pi Pico and MicroPython.
Raspberry Pi Pico with MicroPython - GPIO Mastery
In this lesson, you will learn:
Potentiometers are three-terminal resistors with a sliding contact that forms a variable voltage divider. By adjusting the position of the sliding contact, the output voltage can be varied between the input voltage and ground. You can learn more about how potentiometers work here.
Potentiometers
To connect a potentiometer to your Raspberry Pi Pico board, follow these steps:
To read potentiometer values using MicroPython, you can use the machine.ADC module. Hereās some example code to get you started:
machine.ADC
from machine import Pin, ADC import time potentiometer_pin = Pin(26, Pin.IN) adc = ADC(potentiometer_pin) adc.atten(ADC.ATTN_11DB) while True: potentiometer_value = adc.read() print(potentiometer_value) time.sleep(0.1)
In this lesson, you learned how to use potentiometers to control the input voltage to the Raspberry Pi Pico board, and how to read potentiometer values using MicroPython. You can use this knowledge to create a variety of projects with your Raspberry Pi Pico board.
After you have completed this lesson, you will know how to use potentiometers with the Raspberry Pi Pico and MicroPython. You will be able to connect a potentiometer to the Pico, write MicroPython code to read potentiometer values, and understand the basics of potentiometer operation.
< Previous Next >