cfredisded
Active member
I'm trying to read the value of A3 and A12 at the same time. I want to use the audio library to read an input from an analog instrument and then a potentiometer to also be read to change values in the code. The pot works normally giving values from 0-1023 until I add the adc1 module. When I add 'AudioInputAnalog adc1;' the pot gives values from 12-65535 and stops going up in value at about the 12 oclock position Here's the code I've narrowed down:
I did find this previous post about bit resolution:
https://forum.pjrc.com/threads/41911-Teensy-3-6-ADC-resolution
But does that mean if we are using the adc module from the audio library none of the other analog reads will work?
I did read in the side bar of the adc module:
"analogRead() must not be used, because AudioInputAnalog is regularly accessing the ADC hardware. If both access the hardware at the same moment, analogRead() can end up waiting forever, which effectively crashes your program."
but does that mean analog read on the pin your using as an adc or all analog pins?
Sorry if this a dumb question I'm quite new to programming and the teensy.
*just realized this should probably be in the technical questions catagory
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
//AudioInputAnalog adc1; //xy=623,339 <<<<-------this breaks A12
// GUItool: end automatically generated code
const int analogPin12 = A12; // pot2
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int read12 = analogRead(analogPin12); //Read pot2
Serial.println(read12);
}
I did find this previous post about bit resolution:
https://forum.pjrc.com/threads/41911-Teensy-3-6-ADC-resolution
But does that mean if we are using the adc module from the audio library none of the other analog reads will work?
I did read in the side bar of the adc module:
"analogRead() must not be used, because AudioInputAnalog is regularly accessing the ADC hardware. If both access the hardware at the same moment, analogRead() can end up waiting forever, which effectively crashes your program."
but does that mean analog read on the pin your using as an adc or all analog pins?
Sorry if this a dumb question I'm quite new to programming and the teensy.
*just realized this should probably be in the technical questions catagory
Last edited: