properly map values

master
shark 6 years ago
parent a6e18b7bb8
commit e35fa13802

@ -14,7 +14,7 @@ void loop() {
//average += 256-log(256-analogRead(0) / 4) * (256 /5.55); // old linearization //average += 256-log(256-analogRead(0) / 4) * (256 /5.55); // old linearization
// linearization using resistance to lux relationship // linearization using resistance to lux relationship
average += (1250000.0 * pow(1023 - analogRead(0), -1.4059) - 73) / 2.08; average += map(1250000.0 * pow(1023-analogRead(0), -1.4059), 73, 339, 0, 128);
delay(3); delay(3);
} }
average /= ss; average /= ss;

Loading…
Cancel
Save