From: eaman Date: Wed, 12 Oct 2016 17:37:27 +0000 (+0200) Subject: Errata analog out X-Git-Url: http://git.piffa.net/web?p=sketchbook_andrea;a=commitdiff_plain;h=a7a9d418be7df9054c1c81c5d4ff4dd5262e9d9a Errata analog out --- 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);