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

Thread: Toubles on analogRead() on Teensy 4.1

  1. #1
    Junior Member
    Join Date
    Jun 2020

    Toubles on analogRead() on Teensy 4.1


    I've been working on teensy 4.1 for a year now and recently came into mind blowing troubles.

    I have two teensy board that cannot read anologRead() anymore.
    I started over with the basic tutorial as I was very confused, and it worked well until the analogInput() sketch. So it looks like it can digitalWrite(), digitalRead(), and analogWrite() but no more analogRead(). The input value is ever 8-12 or 1010-1014 and does not react to anything, even my fingers (which I used to use to make the value move a bit).
    The audioBoard still works well with the ladder filter swipping in standalone mode.
    The problem is very recent and occured on a first teensy 4.1, so I took one new as I thought I would have done something wrong with the previous one, but both do the same. I have tried a few previous settings of pinMode() also... I doubt you can reproduce this at home but if you have any clue on that ?

    int pin = 11;
    int ledPin = 13;
    void setup()
      pinMode(ledPin, OUTPUT);
      //pinMode(pin, INPUT_PULLUP);
      //digitalWrite(pin, HIGH);
    void loop()         
      Serial.println("analog "+String(pin) + " is " + analogRead(pin) );
      digitalWrite(ledPin, !digitalRead(ledPin));  
    Click image for larger version. 

Name:	IMG_20210417_234413_1.jpg 
Views:	7 
Size:	135.5 KB 
ID:	24485 Click image for larger version. 

Name:	IMG_20210417_234326.jpg 
Views:	5 
Size:	124.2 KB 
ID:	24486

    By the way, after spending hours trying to understand why I had a gap in analogRead() from around 495 to 550, even with averaging and precision settings, I found out that using digitalWrite(LOW) on the pin would resolve that (Thanks to the ResponsiveAnalogRead library which is definitly what we should use).

    Thanks a lot.

  2. #2
    Senior Member
    Join Date
    Jul 2020
    The analog pins for the T4.1 are 14--27 and 38-41 according to the info card with the pinouts. You are using
    pin 11 which is digital only.

  3. #3
    Junior Member
    Join Date
    Jun 2020
    Thanks a lot for your quick answer, what a stupid error of mine ! (I actually made a custom document out of teensy connections card fort my pinouts, which was hidding analog infos...)
    I should have asked before...
    Thanks anyway for the help and reactivity, maybe this thread could be deleted...

Posting Permissions

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