4 Utilizzare una fotoresistenza come analog input.
5 Il comportamento della foto resistenza e' simile
6 a un potenziometro: varia la resistenza in base alla
9 Per ottenere valori significativi utilizzare unaresistenza
10 da ~5k ohms in serie con il sensore.
12 Questo sketch modifica l'intervallo di intermittenza di un led
13 in base alla luminosita' rilevata.
16 int sensorPin = A0; // select the input pin for the potentiometer
17 int ledPin = 13; // select the pin for the LED
18 int sensorValue = 0; // variable to store the value coming from the sensor
21 // declare the ledPin as an OUTPUT:
22 pinMode(ledPin, OUTPUT);
23 // initialize serial communications at 9600 bps:
28 // read the value from the sensor:
29 sensorValue = analogRead(sensorPin);
31 digitalWrite(ledPin, HIGH);
32 // stop the program for <sensorValue> milliseconds:
34 // turn the ledPin off:
35 digitalWrite(ledPin, LOW);
36 // stop the program for for <sensorValue> milliseconds:
37 // print the results to the serial monitor:
38 Serial.print("sensor = " );
39 Serial.print(sensorValue);
40 Serial.print("\t delay = ");
41 Serial.println(sensorValue);
46 1. qual'e' il valore minimo rilevato?
48 3. Come adattare la risoluzione dell'attuatore alla sensibilita' del sensore?