Below is the schematic drawing of the circuit
I have created the circuit so that inside in a dark room, the blue light would turn on, inside a regular NYUAD room light, there would be yellow light and inside a bright room, the red light would turn on.
Here is the demonstration:
Finally, this is the code for what I have done:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode (13, OUTPUT);
pinMode (12, OUTPUT);
pinMode (11, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
if(sensorValue <50) {
digitalWrite (11, HIGH);
} else {
digitalWrite (12, LOW);
digitalWrite (13, LOW);
}
if(sensorValue < 450 && sensorValue > 51) {
digitalWrite (11, LOW);
digitalWrite (13, HIGH);
digitalWrite (12, LOW);
}
if(sensorValue > 450) {
digitalWrite (12, HIGH);
digitalWrite (11, LOW);
digitalWrite (13, LOW);
}
delay(1);
}
Yellow light = 13, Blue Light = 12, Red Light = 11