3 Demonstrates analog input by reading an analog sensor on analog pin 0 and
4 turning on and off a light emitting diode(LED) connected to digital pin 13.
5 The amount of time the LED will be on and off depends on
6 the value obtained by analogRead().
9 * Potentiometer attached to analog input 0
10 * center pin of the potentiometer to the analog pin
11 * one side pin (either one) to ground
12 * the other side pin to +5V
13 * LED anode (long leg) attached to digital output 13
14 * LED cathode (short leg) attached to ground
16 * Note: because most Arduinos have a built-in LED attached
17 to pin 13 on the board, the LED is optional.
20 Created by David Cuartielles
24 This example code is in the public domain.
26 http://arduino.cc/en/Tutorial/AnalogInput
28 Schema: http://lab.piffa.net/schemi/potenziometro_bb.png
32 int sensorPin = A0; // select the input pin for the potentiometer
33 int ledPin = 13; // select the pin for the LED
34 int sensorValue = 0; // variable to store the value coming from the sensor
37 // declare the ledPin as an OUTPUT:
38 pinMode(ledPin, OUTPUT);
39 // Non e' necessario dichiarare un pin come input:
40 // tutti i pin di default sono input
44 // read the value from the sensor:
45 sensorValue = analogRead(sensorPin);
47 digitalWrite(ledPin, HIGH);
48 // stop the program for <sensorValue> milliseconds:
50 // turn the ledPin off:
51 digitalWrite(ledPin, LOW);
52 // stop the program for for <sensorValue> milliseconds: