113270 Views
93709 Views
85773 Views
53388 Views
50571 Views
48758 Views
Operation Pico
Raspberry Pi Home Hub
Hacky Temperature and Humidity Sensor
Robot Makers Almanac
High Five Bot
Making a Custom PCB for BurgerBot
Using the Raspberry Pi Pico's Built-in Temperature Sensor
Getting Started with SQL
Introduction to the Linux Command Line on Raspberry Pi OS
How to install MicroPython
Wall Drawing Robot Tutorial
BrachioGraph Tutorial
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 >