Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Analog read problem with T4.1

  1. #1
    Junior Member
    Join Date
    Jun 2021
    Posts
    4

    Analog read problem with T4.1

    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

  2. #2
    Junior Member
    Join Date
    Jun 2021
    Posts
    4
    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.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,750
    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

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,252
    Quote Originally Posted by Keith B View Post
    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.

  5. #5
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    1,074
    Possibly different on the T4, but "INPUT" means "digital input". So either don't use pinMode() at all or use pinMode(n, INPUT_DISABLE).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •