106994 Views
83035 Views
47973 Views
47955 Views
47413 Views
46546 Views
Two-Way Bluetooth Communication Between Raspberry Pi Picos
Gamepad 2
Picotamachibi 2
Learning System updates
BrachioGraph
HP Robots Otto
Introduction to the Linux Command Line on Raspberry Pi OS
How to install MicroPython
Wall Drawing Robot Tutorial
BrachioGraph Tutorial
Intermediate level MicroPython
Introduction to FreeCAD for Beginners
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 >