// This is part of an exercise to ask students to change this sketch so that
// an LDR is read instead of a Potentiometer
// readings should be able to be seen using the Serial.println
int sensorPin = A5; // select the input pin for the potentiometer on the ThinkerShield
int ledPin = 12; // select the pin for the LED – 12 on the ThinkerShield
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600); // tell the software to begin transmitting the value given below using serial communication
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(sensorValue); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(sensorValue); // stop the program for some time
// Serial.println("The sensor value is " + sensorValue);
// in serial monitor write “The sensor value is”
Serial.print("The sensor value is: ");
// put the sensor value in serial monitor after the wording given in the line above this.
Serial.println(sensorValue);
}