Klasse ADC
¶
Beispiel
# Import ADC class
from robot_hat import ADC
# Create ADC object with numeric pin numbering
a0 = ADC(0)
# Create ADC object with named pin numbering
a1 = ADC('A1')
# Read ADC value
value0 = a0.read()
value1 = a1.read()
voltage0 = a0.read_voltage()
voltage1 = a1.read_voltage()
print(f"ADC 0 value: {value0}")
print(f"ADC 1 value: {value1}")
print(f"ADC 0 voltage: {voltage0}")
print(f"ADC 1 voltage: {voltage1}")
API
- class robot_hat.ADC(chn, address=None, *args, **kwargs)¶
Basisklasse:
I2C
Analog-Digital-Wandler
- __init__(chn, address=None, *args, **kwargs)¶
Analog-Digital-Wandler
- Parameter
chn (int/str) – Kanalnummer (0-7/A0-A7)
- read()¶
ADC-Wert lesen
- Rückgabe
ADC-Wert (0-4095)
- Rückgabetyp
int
- read_voltage()¶
ADC-Wert lesen und in Spannung umwandeln
- Rückgabe
Spannungswert (0-3.3(V))
- Rückgabetyp
float