Analog read affected by multiple pots using the Audio Shield

Status
Not open for further replies.
Hi PJRC Forum,

I would like to read a value from an analog pin A0 on Teensy 4 while also having another pot wired to A1, both 50K pots.
For my purpose, the middle pot pins are wired to A0 and A1, the left pins to GND and right ones to +5V, no additional resistors.
It is important to note that my teensy is also soldered to an Audio Shield. I am using a breadboard to test everything.

The code:
Code:
#include <Arduino.h>

void setup()
{                
  Serial.begin(38400);
}

int val;

void loop()                     
{
  val = analogRead(14);
  Serial.print("analog 0 is: ");
  Serial.println(val);
  delay(50);
}
My problem starts while reading the value of analogRead(A0); it seems to change based on the values of other pots wired to the Teensy.
In other words, turning other pots seems to affect the value of the A0 pin I am reading.
In addition, the value of the read reaches 1023 already when the pot is about 3/4 turned.

I have read online about reading the pin twice but this has not solved my issue.
The problem seems to amplify with additional pots wired to the Teensy and being altered.
Using an almost identical code and wiring, I have tested the problem on Arduino Nano and Uno; no pins affect each other at all.

What am I doing wrong here? Is it the Audio Shield? Perhaps I need some pull-down resistors or different pot values?
My ultimate project involves a set of buttons and pots.
Pressing a specific button should trigger a button-specific code; however, twisting the pots in my project affects the value of the button read with analogread, making Teensy wrongly recognize which button is pressed.

Thanks for your help!
 
The Teensy 4.0 is a 3.3V device, connecting analog pins to 5V will destroy it. Your potentiometers should be wired to 3.3V, not 5V.

Pieter
 
50k is a bit high for ADC use, as this means the ADC multiplexer sees upto 25k impedance from the pot.
When switching between pots the charge stored on the sample&hold capacitor of the ADC can lead to crosstalk
between inputs unless the impedance is low enough to keep this below 1 LSB.

10k pots are a good default choice, keeping the impedances at/below 5k. This will also reduce the effect of
capacitive noise pickup in wiring between microcontroller and the pots themselves.

But if 50k is working fine for you, no problem, I'd just be aware that such issues can arise.
 
Status
Not open for further replies.
Back
Top