Using an LDR (Light Dependent Resistor) with Arduino to Measure Light Intensity. Components Needed: Arduino board LDR (photoresistor) 10kΩ resistor Breadboard and jumper wires Circuit Connections: LDR : Connect one leg of the LDR to 5V on the Arduino, and the other leg to an analog input pin (e.g., A0). Resistor : Connect a 10kΩ resistor between the LDR leg (that goes to the analog pin) and GND. This forms a voltage divider. Explanation: When light falls on the LDR, its resistance changes, affecting the voltage at the analog pin. The analog pin reads a value between 0 and 1023 depending on the light intensity. Example Code: C++ Code int ldrPin = A0; // Analog pin to which LDR is connected int ldrValue; void setup () { Serial. begin ( 9600 ); // Start the serial communication to view the LDR value } void loop () { ldrValue = analogRead (ldrPin); // Read the LDR value Serial. println (ldrValue); // Print the value to the Serial Monitor delay ( 500 ); // Delay for...
Comments
Post a Comment