Map value problem;
Although the value read is 1023, result is sometimes 11 en sometimes 12 ????
How can than be?
Basic Code (not actual program!):
ValMap = map(analogRead(A0), 0, 1023, 0 , 12);
Serial.print(analogRead(A0), DEC);Serial.println(ValMap, DEC);
Result on screen
1023 - 11
1023 - 11
1023 - 12
1023 - 12
1023 - 11
Look at the first two lines of the code, let me quote:
ValMap = map(analogRead(A0), 0, 1023, 0 , 12);
Serial.print(analogRead(A0), DEC);
You're making two different measurements on these lines. Try changing it to the following:
int val1=analogRead(A0);
ValMap = map(val1, 0, 1023, 0 , 12);
Serial.print(val1, DEC)
//Basel