]> git.piffa.net Git - sketchbook_andrea/blobdiff - basic/analog_input/photo_6_smooth/photo_6_smooth.ino
Flasher con millis
[sketchbook_andrea] / basic / analog_input / photo_6_smooth / photo_6_smooth.ino
index 60913fe2414f3bdb931ce91f6a603f3de62ac5cf..3f27170ac1f79c3edcf6aeba0675d46c9734233a 100644 (file)
@@ -64,9 +64,14 @@ int smoothRead(int sensorPin) {
   int total = 0;
   for (int i = 0; i < 10; i++) { 
     total = total + analogRead(sensorPin);
-    delay(2); // Pausa per assestare il senstore
+    delay(2); // Pausa per assestare il sensore
   }
   return(total / 10); // Valore medio
+  /* Nota: i microcontroller non sono bravi a fare le divisioni,
+     sarebbe piu' efficiente ottenere 8 valori e fare uno shift dx. di 3 bit
+     total = total >> 3 ;
+Vedi: https://www.arduino.cc/en/Reference/Bitshift
+   */
 }