when the room light is turned off, the led activates!
I pulled a value from a simple photoresistor to make this happen. The arduino code is posted bellow.
int led = 8;
void setup() {
Serial.begin(9600);
pinMode(led,OUTPUT);
}
void loop() {
int sensorValue = analogRead(A1);
sensorValue = map(sensorValue,0,1024,0,500);
Serial.println(sensorValue);
delay(1);
if (sensorValue < 34) {
digitalWrite(led,HIGH);
} else {
digitalWrite(led,LOW);
}
}
void setup() {
Serial.begin(9600);
pinMode(led,OUTPUT);
}
void loop() {
int sensorValue = analogRead(A1);
sensorValue = map(sensorValue,0,1024,0,500);
Serial.println(sensorValue);
delay(1);
if (sensorValue < 34) {
digitalWrite(led,HIGH);
} else {
digitalWrite(led,LOW);
}
}