Created
February 12, 2021 01:27
-
-
Save scruss/ba3d3b33b99850c322f5b6e301591aff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# micropython for raspberry pi pico | |
# potentiometer between AGND and 3V3, with the wiper going to ADC pin 2 | |
# prints 0-100 depending on how far potentiometer is turned | |
# 3 columns so the Thonny plotter will scale correctly | |
from machine import Pin, ADC | |
from time import sleep | |
led = Pin(25, Pin.OUT) | |
adc = ADC(2) | |
while True: | |
v = adc.read_u16() | |
print('0.0 %10.5f 100.0' % (100 * float(v)/65535)) | |
led.toggle() | |
sleep(0.1) |
You've only got two wires, so your potentiometer is a only variable resistor. It should give output from 0–100 when turned the full range
The wiring should look like this:
https://scruss.com/wordpress/wp-content/uploads/2021/02/PicoPot_bb.png
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Scruss,
It worked. I used a B100k digikey and the printed result varied from ~ 0.45 to 1.68 turning the nub all the way around.
scruss_potentiometer.mp4