Smoothing
Legge 10 valori dal sensore e ritorna il valore medio tra questi.
+
+ Schema: https://learn.adafruit.com/assets/460
+
*/
// These constants won't change:
const int sensorPin = A0; // pin that the sensor is attached to
-const int ledPin = 9; // pin that the LED is attached to
+const int ledPin = 11; // pin that the LED is attached to
// variables:
int sensorValue = 0; // the sensor value
void setup() {
// turn on LED to signal the start of the calibration period:
pinMode(13, OUTPUT);
+ pinMode(ledPin, OUTPUT);
digitalWrite(13, HIGH);
// calibrate during the first five seconds
total = total + analogRead(sensorPin);
delay(2); // Pausa per assestare il senstore
}
- return(total / 10);
+ return(total / 10); // Valore medio
}