// Arduino Light sensor code created by AR Builder. //#include int pinLED = PB2; // Declare the pinLED PB2 as an OUTPUT int pinLIGHTSens = 3; // Declare the pinLIGHTSens as an INPUT // Setting variables int sensorValue = 0; //Variable to store the value coming from the light sensor int threshold = 200; void setup() { pinMode(pinLED,OUTPUT); pinMode(pinLIGHTSens,INPUT); digitalWrite(pinLED, HIGH); //Serial.begin(9600); // Set and start serial port for communication } void loop() { sensorValue = analogRead(pinLIGHTSens); // Read the value from the sensor //Display serial results in serial monitor: //Serial.println(sensorValue); // Prints the values coming from the sensor on the screen if (sensorValue < threshold) { // Change 100 to the number depending on the light in your area digitalWrite(pinLED, HIGH); } else { digitalWrite(pinLED, LOW); } delay(100); }