3 Analog input A0 to measure an LDR
7 int sensorPin = A0; // select the input pin for the potentiometer
8 int sensorValue = 0; // variable to store the value coming from the sensor
14 //Initialize serial and wait for port to open:
17 ; // wait for serial port to connect. Needed for Leonardo only
19 // prints title with ending line break
20 Serial.println("Serial port ready.");
24 // read the value from the sensor:
25 sensorValue = analogRead(sensorPin);
28 // stop the program for <sensorValue> milliseconds:
31 // prints value as string as an ASCII-encoded decimal (base 10).
32 // Decimal is the default format for Serial.print() and Serial.println(),
33 // so no modifier is needed:
34 Serial.println(sensorValue);