X-Git-Url: http://git.piffa.net/web?p=sketchbook_andrea;a=blobdiff_plain;f=basic%2Fanalog_input%2Fphoto_6_smooth%2Fphoto_6_smooth.ino;fp=basic%2Fanalog_input%2Fphoto_6_smooth%2Fphoto_6_smooth.ino;h=3f27170ac1f79c3edcf6aeba0675d46c9734233a;hp=60913fe2414f3bdb931ce91f6a603f3de62ac5cf;hb=0662b12752ee761efee7077b63c77f294e98deda;hpb=2833f00daaa67fa16122dc20873a1f00a346abf8 diff --git a/basic/analog_input/photo_6_smooth/photo_6_smooth.ino b/basic/analog_input/photo_6_smooth/photo_6_smooth.ino index 60913fe..3f27170 100644 --- a/basic/analog_input/photo_6_smooth/photo_6_smooth.ino +++ b/basic/analog_input/photo_6_smooth/photo_6_smooth.ino @@ -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 + */ }