I need this for 12 bit res, for the digital encoder the readings are stable, but when analog in is on ±1,2 variations appearing
This is the part:
#include <Encoder.h>
Encoder enc2(3, 4);
void setup(){
Serial.begin(9600);
}
void loop(){
float frqA;
const int threshold = 200; //
int analogValue = analogRead(A0);
if (analogValue > threshold) {
frqA = map(analogRead(A0), 0, 4095, 0, 4092);
}
else
{
int val1 = enc2.read(); //freqA of Wavetable **0 -> 2^32
if(val1 <= 0) { // constrain for below 0
enc2.write(0); // constrain the encoder object
}
else if(val1 >= 1000){
enc2.write(1000);
}
frqA = constrain(val1,0.1,1000.00)*4.092; // (=1x..hz..)
}
Serial.print(" freqA:");
Serial.print(frqA);
}
What do you think?