]> git.piffa.net Git - sketchbook_andrea/blobdiff - oggi/photo_5_calibration/photo_5_calibration.ino
Errata analog out
[sketchbook_andrea] / oggi / photo_5_calibration / photo_5_calibration.ino
index 1d9b4d75f35f6d607f1aebbff02156aa201851e9..ede9ca8fda53acb52457ae3982e91cefe6931980 100644 (file)
@@ -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);