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 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
19 - http://www.pighixxx.com/test/portfolio-items/connect-a-photoresistor/
21 Divisori di voltaggio:
22 - https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity
23 - https://learn.sparkfun.com/tutorials/voltage-dividers
24 - http://www.pighixxx.com/test/wp-content/uploads/2014/10/126.png
27 int sensorPin = A0; // select the input pin for the potentiometer
28 int ledPin = 13; // select the pin for the LED
29 int sensorValue = 0; // variable to store the value coming from the sensor
32 // declare the ledPin as an OUTPUT:
33 pinMode(ledPin, OUTPUT);
34 // initialize serial communications at 9600 bps:
39 // read the value from the sensor:
40 sensorValue = analogRead(sensorPin);
42 digitalWrite(ledPin, HIGH);
43 // stop the program for <sensorValue> milliseconds:
45 // turn the ledPin off:
46 digitalWrite(ledPin, LOW);
48 // stop the program for for <sensorValue> milliseconds:
49 // print the results to the serial monitor:
50 Serial.print("sensor = " );
51 Serial.print(sensorValue);
52 Serial.print("\t delay = ");
53 Serial.println(sensorValue);
58 1. qual'e' il valore minimo rilevato?
60 3. Come adattare la risoluzione dell'attuatore alla sensibilita' del sensore?
61 4. A cosa serve la resistenza da 10 - 5k ohms ?
80 3. Vedi esercizio suciessivo
81 4. Serve come pull down per il pin che altrimenti sarebbe un sensore
82 ad alta impendenza flottante e come divisore di voltaggio.