Go Down

Topic: Analog input stability (Read 556 times) previous topic - next topic

adwsystems

I'm sure the double dead of A0 doesn't help

Code: [Select]
int analogValue = analogRead(A0);  // <=========== First read
if (analogValue > threshold) {
  frqA = map(analogRead(A0), 0, 4095, 0, 4092); // <=========== Second read
  }
  else


@OP: I suggest you change
frqA = map(analogRead(A0), 0, 4095, 0, 4092);

to

frqA = map(analogValue, 0, 4095, 0, 4092);

for two reasons:
1. analogRead is slow and blocking. So it is best to minimize their use.
2. the value may change on a second read. The original premise of the thread was questioning analog read stibility

Go Up