From a7a9d418be7df9054c1c81c5d4ff4dd5262e9d9a Mon Sep 17 00:00:00 2001 From: eaman Date: Wed, 12 Oct 2016 19:37:27 +0200 Subject: [PATCH] Errata analog out --- oggi/photo_5_calibration/photo_5_calibration.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oggi/photo_5_calibration/photo_5_calibration.ino b/oggi/photo_5_calibration/photo_5_calibration.ino index 1d9b4d7..ede9ca8 100644 --- a/oggi/photo_5_calibration/photo_5_calibration.ino +++ b/oggi/photo_5_calibration/photo_5_calibration.ino @@ -39,8 +39,10 @@ int sensorMax = 0; // maximum sensor value void setup() { // turn on LED to signal the start of the calibration period: pinMode(13, OUTPUT); + pinMode(9, OUTPUT); digitalWrite(13, HIGH); + // calibrate during the first five seconds while (millis() < 5000) { sensorValue = analogRead(sensorPin); @@ -66,7 +68,7 @@ void loop() { sensorValue = analogRead(sensorPin); // apply the calibration to the sensor reading - sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255); + sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 254); // in case the sensor value is outside the range seen during calibration sensorValue = constrain(sensorValue, 0, 255); -- 2.39.2