Potentiometer¶

Description |
Often referred to as a knob. The potentiometer can be physically turned. It returns a value based on the position it is set to. |
Usage |
Reads a raw analog position as a variable resistance. With micro:bit ADC input this would range from 0 to 1023. |
Voltage Range |
3 - 5V |
Interface Type |
Analog Input |
Example Usage |
from microbit import *
def convert_pos_to_pcnt(raw_pos):
return int(100 * (raw_pos / 1023))
while True:
pos_val = pin0.read_analog()
pos_pcnt = convert_pos_to_pcnt(pos_val)
# ...do something with percent
|