Problem with multiple ADCs
Posted: Mon Jun 16, 2014 10:12 am
I'm having some problems with reading from multiple ADC pins. I have two potentiometers hooked up to X7 and X8, but one of the pots controls both readings, while the other one has no effect. Here's the code that I'm using for testing:
The values printed are not exactly the same (but close) and increase and decrease when the pot on X8 is turned.
If the order of the declarations is changed then it is the pot on X7 that has the effect (i.e. the last ADC pin configured is effective). I tried it on X11 and X12 as well, with the same result.
Could this be a bug in the ADC class or am I not using it correctly?
Code: Select all
from pyb import ADC
import pyb
if __name__ == "__main__":
switch = pyb.Switch()
pyb.delay(5000)
if switch():
pot_1 = ADC(pyb.Pin.board.X7)
pot_2 = ADC(pyb.Pin.board.X8)
while True:
print("pot_1:", pot_1.read(), "pot_2", pot_2.read())
pyb.delay(1000)
If the order of the declarations is changed then it is the pot on X7 that has the effect (i.e. the last ADC pin configured is effective). I tried it on X11 and X12 as well, with the same result.
Could this be a bug in the ADC class or am I not using it correctly?