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.
15 Schema: http://lab.piffa.net/schemi/photoresistor_led.png
18 int sensorPin = A0; // select the input pin for the potentiometer
19 int ledPin = 13; // select the pin for the LED
20 int sensorValue = 0; // variable to store the value coming from the sensor
23 // declare the ledPin as an OUTPUT:
24 pinMode(ledPin, OUTPUT);
25 // initialize serial communications at 9600 bps:
30 // read the value from the sensor:
31 sensorValue = analogRead(sensorPin);
33 digitalWrite(ledPin, HIGH);
34 // stop the program for <sensorValue> milliseconds:
36 // turn the ledPin off:
37 digitalWrite(ledPin, LOW);
38 // stop the program for for <sensorValue> milliseconds:
39 // print the results to the serial monitor:
40 Serial.print("sensor = " );
41 Serial.print(sensorValue);
42 Serial.print("\t delay = ");
43 Serial.println(sensorValue);
48 1. qual'e' il valore minimo rilevato?
50 3. Come adattare la risoluzione dell'attuatore alla sensibilita' del sensore?