Aq0amancer
Member
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:
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!
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);
}
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!