Analog read problem with T4.1

Status
Not open for further replies.

Keith B

New member
Hello,

I appear to be having a problem with analogueRead using T4.1

I have a simple setup, a potentiometer wired to 3.3v and Gnd, with the sweeper pin connected to A14.
I am reading the analog value using analogRead(14) and simply displaying this on the serial port.

As I sweep the potentiometer, I get value printed out from 0 to 1023 as expected. However, around the centre point there is a gap between 490 and 590 ( when turning the pot CW) and a gap between 560 and 460 when rotating the pot CCW.

I get the same results when connected to A15 as well.

Any ideas when this could be?

Thanks in advance
Keith
 
After further tests and searching on this forum, I believe I've got a fix in adding a pinMode(A14, INPUT) line in the setup code.

Not sure why this would fix the problem, but it appears to work.
 
Just an FYI: pin 14 and A14 are not the same thing. pin 14 is the analog pin referred to as A0. A14 is on pin 38.

Pete
 
Any ideas when this could be?

I think this is the pin being in Schmitt-trigger mode, ie deliberate hysteresis circuit is active. I suspect this may
be the chip default at reset (to prevent power drain from floating inputs). I presume setting INPUT selects a
truely floating input mode - but this is only my guess.
 
Possibly different on the T4, but "INPUT" means "digital input". So either don't use pinMode() at all or use pinMode(n, INPUT_DISABLE).
 
Status
Not open for further replies.
Back
Top