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

Thread: Analog pins not being read on Teensy 4.1

  1. #1
    Junior Member
    Join Date
    Oct 2021
    Posts
    2

    Analog pins not being read on Teensy 4.1

    Hi! I have written a simple code to read the raw accelerometer values from the ADXL 335 breakout board and I'm using Teensy 4.1.

    The ccelerometer ADXL 335 breakout board is powered with 3.3 V and the axis pins connected to analog pins 13,14,15 on Teensy 4.1. I am getting spurios values like 3,6,10.

    How can i get the correct ADC levels as the output? I've also tried changing to different analog pins and the same problem persists.

    Code:
    Code:
    int Xpin=13;
    int Ypin=14;
    int Zpin=15;
    
    int xRaw, yRaw, zRaw;
    
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() 
    {
      xRaw=analogRead(Xpin);
      yRaw=analogRead(Ypin);
      zRaw=analogRead(Zpin);
      
      Serial.print("X: ");
      Serial.print(xRaw);
      Serial.print("  Y: ");
      Serial.print(yRaw);
      Serial.print("  Z: ");
      Serial.println(zRaw);
      
      delay(1000);
    }

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,271
    Pin 13 doesn't have Analog read ability.

    Try:
    Code:
    int Xpin=??;
    int Ypin=A0;  // pin 14
    int Zpin=A1;  // pin 15
    Or perhaps this was meant?
    Code:
    int Xpin=A13;  // pin 27
    int Ypin=A14;  // pin 38
    int Zpin=A15;  // pin 39

  3. #3
    Junior Member
    Join Date
    Oct 2021
    Posts
    2
    pin 13 is my bad... Found soldering problems on my breakout board and i'll have to get that rectified. Thanks!

Posting Permissions

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