troubleshooting Question

Arduino

Avatar of Dier Eluom
Dier Eluom asked on
Embedded Hardware
3 Comments1 Solution186 ViewsLast Modified:
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 pin
int 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);
  
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros