Analog (ADC) Inputs on the Raspberry Pi Pico with MicroPython

  Переглядів 14,313

Brad Henson

Brad Henson

День тому

In this video we are going to learn how read analog inputs using the Raspberry Pi Pico and build a circuit to include a potentiometer. With this we will be able to adjust and read voltages across the range from 0 to 3.3 volts. To accomplish this, we will use the Analog to Digital Converter built right into our microcontroller.
00:00 Intro
00:30 ADC Introduction
01:30 Pico's ADC Channels
02:03 What is a Potentiometer
02:27 Circuit Build
02:42 Programming the Pico's ADC
03:28 Converting ADC output to a voltage
03:57 Recap
The parts you will need to follow along with this video are:
1x Raspberry Pi Pico
1x Micro USB Cable
1x Breadboard
1x 10k Potentiometer
3x Jumper Wires
Hardware Links:
Elegoo Electronics Kit: amzn.to/3aKWJA7​
Breadboard: amzn.to/2Npu9f5​
www.adafruit.com/product/4864​​
www.sparkfun.com/products/17829​
Helpful Links:
www.raspberrypi.org/products/...
www.raspberrypi.org/documenta...
micropython.org/download/rp2-...
thonny.org/​

КОМЕНТАРІ: 25
@run4yourlife12
@run4yourlife12 3 роки тому
Very interesting stuff Brad! I always learn something new with your videos. Can’t wait to learn about controlling the brightness of an LED!
@humanbagel
@humanbagel 2 роки тому
Great production quality! subbed!
@aem870
@aem870 2 роки тому
Good job, clear to understand 💯
@user-xx5kw3wt1l
@user-xx5kw3wt1l 3 роки тому
Nice video !
@hindenberg25557
@hindenberg25557 3 роки тому
Concise and helpful! Currently trying to read from a strain gauge that maxes out at 3.5V, so hopefully not damaging the pico.
@hensonbl
@hensonbl 3 роки тому
Thank you. I think you will be okay, but something to consider is using a voltage divider to limit the voltage being read into the ADC pin.
@hindenberg25557
@hindenberg25557 3 роки тому
@@hensonbl Thanks for the tip! Also wanted to suggest a video topic if you think others would find it useful. If you are powering the pico from a PI4 or similar via USB, it would make sense to consider also sending/receiving data over USB. There's some forum discussion about it but no decent tutorial that I'm aware of.
@contextualcoding1884
@contextualcoding1884 3 роки тому
awesome!
@allthegearnoidea6752
@allthegearnoidea6752 Рік тому
Great video thanks very interesting and enjoyable
@hensonbl
@hensonbl Рік тому
Glad you enjoyed it
@lastdraco1
@lastdraco1 3 роки тому
I like it.
@miladiouss
@miladiouss 2 роки тому
Can I send the data to a local script to plot the voltage on my PC?
@kaggavin1007
@kaggavin1007 2 роки тому
Hi Brad, please assist on how to add a command that enables an output GPIO when the voltage(ADC(26)) is above 2.3 V and disables when the voltage is or below 2.2 v
@zz3709
@zz3709 Рік тому
Why the low end limit of 400? It's this a limitation of the Pico's ADC HW? Or micropython? Or... ?
@warandv6614
@warandv6614 3 роки тому
Could you make a video on how to control LED strips (Red to Violet) using a potentiometer ? Most LED strups are 5V so the 3.3 GPIO output wouldn't work
@hensonbl
@hensonbl 3 роки тому
I will look into doing a video on that. The quick answer is to use a MOSFET with a really low Gate Threshold Voltage. The IRLB8721PbF MOSFET would be a good choice since it has a threshold voltage of 2.35 and it is in a TO-220 package for greater current capability.
@warandv6614
@warandv6614 3 роки тому
@@hensonbl i see, is there a way to convert the potentiometer input to RGB (x,x,x) values ? think that would be faster considering we already have the ws2812b library
@hensonbl
@hensonbl 3 роки тому
I was thinking about the hardware hookup, and if you are only controlling 30 or less ws2812b LEDs, you could simply use Pin 40 (VBUS) on the pico as the 5V source for the LED strip. As for mapping an RGB value based on a potentiometer input, I don't have a quick and easy solution. You could look at using the matplotlib python library, but I don't know if the pico will support it. stackoverflow.com/questions/39357633/how-do-i-convert-a-single-potentiometer-value-to-r-g-b
@deniszawad
@deniszawad 2 роки тому
interesting but at 2.35 in the video you show a misleading representation of the pin 26 location on the pico it would be nice to get abtter appreciaton of the position an an ID of the pin. keep on your good work.
@jyvben1520
@jyvben1520 3 роки тому
nice, only 3 typo's, luckily not in the code thonny user : print(dir(umachine)) shows all the options or do help(umachine) umachine, utime, micropython, rp2, uos or any library name (or part of) you imported, e.g. part => I2C, SPI, softI2C, softSPI, Pin, sleep, sleep_ms, const, localtime
@MatthewHarrold
@MatthewHarrold 3 роки тому
Liked and sub'd. How could I not?
@hensonbl
@hensonbl 3 роки тому
That's awesome, I'm glad to hear that.
@user-xx5kw3wt1l
@user-xx5kw3wt1l 3 роки тому
from machine import Pin, ADC import utime POT_Value = ADC(26) conversion_factor = 3.3 / (65536) while True: print(POT_Value.read_u16() * conversion_factor) utime.sleep(0.1) thanks me later :p
@caltick
@caltick 2 роки тому
you should have shown how stable the value is over at least 0.111111 Secs, c'mon man my experience shows it is noisy. secondly how do you get 16 bits from 12 bits, c'mon man
@tubeDude48
@tubeDude48 Рік тому
The conversion factor, (3.3), needs to be adjusted per each board.
Arduino vs Pico - Which is the Best Microcontroller For You?
20:38
Gary Explains
Переглядів 277 тис.
#370 Raspberry Pi Pico vs ESP32 (-S2) and STM32 Blackpill
15:53
Andreas Spiess
Переглядів 382 тис.
Что будет с кроссовком?
00:35
Аришнев
Переглядів 2,2 млн
Reading Analog Inputs | Raspberry Pi Pico Workshop: Chapter 2.6
8:46
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
GreatScott!
Переглядів 581 тис.
PWM on the Raspberry Pi Pico with MicroPython
4:47
Brad Henson
Переглядів 10 тис.
What is VGA and How to Use it With a Raspberry Pi Pico
18:28
Gary Explains
Переглядів 48 тис.
Raspberry Pi Pico ADC
14:04
Tinker Tech Trove
Переглядів 15 тис.
In-depth: Raspberry Pi Pico's PIO - programmable I/O!
17:19
stacksmashing
Переглядів 126 тис.
Monitoring Voltage with ESPHome, D1 Mini ADC, and Home Assistant
23:07
Raspberry Pi Pico Lecture 7: ADC and DMA
49:59
Hunter Adams
Переглядів 8 тис.
Top 5 Beginner PCB Design Mistakes (and how to fix them)
12:52
Altium Academy
Переглядів 189 тис.
Как открыть дверь в Jaecoo J8? Удобно?🤔😊
0:27
Суворкин Сергей
Переглядів 942 тис.
ИГРОВОЙ ПК от DEXP за 37 тысяч рублей из DNS
27:53
Ремонтяш
Переглядів 378 тис.