I want a LED to light up if a LDR detects that the light level has dropped. I have another LEd running at the same time that shines on the LDR at 540 nanometres. I want it to detect if the light level drops below 500 nanometres and if so turn on a REd led and if it is above 500 nanometres to turn on a green LED.
int LDRValue = 0; //result of analog pinint ledPin = 13;void setup(){ Serial.begin(9600);//sets a serial port for communication pinMode(ledPin,OUTPUT);}void loop(){ LDRValue = analogRead(LDRpin);//read the value from LDR Serial.println(LDRValue*12.5); //print to serial port digitalWrite(ledPin,HIGH); delay(200);}