#define LIGHT_PIN A0
#define LED_PIN 13
void setup() {
// put your setup code here, to run once:
pinMode(LIGHT_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int lightLevel = analogRead(LIGHT_PIN);
Serial.println(lightLevel);
// if the Light level was low enough, the light turn on
if(lightLevel > 900)
{
digitalWrite(LED_PIN, HIGH);
}
// Else the light level high enoung, the light turn of
else {
digitalWrite(LED_PIN, LOW);
}
}