Analog pins not being read on Teensy 4.1

Status
Not open for further replies.

Ash

Member
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);
}
 
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
 
pin 13 is my bad... Found soldering problems on my breakout board and i'll have to get that rectified. Thanks!
 
Status
Not open for further replies.
Back
Top