when using LDR in Arduino why a resistor need to be added with the LDR??
If I don't mix up things a LDR is like a resistor and its value varies according to light. Using another resistor, with the same value as the LDR exposed for "average light" creates a voltage divider. Feed the divider with Vcc, 5 or 3.3 volt, and read the middle point of the divider with an analog input.
How else would it be done?
You need to Google voltage divider.
Look at this thread.
No, it's to create a simple voltage divider (aka potential divider).
My suggestion is to check out some basic concepts regarding resistors and why they are used.
Instead of using an external resistor I often just use the internal pullup as the LDR load resistor if the sensitivity is acceptable.
Connect the LDR from an input pin and to ground and enable the internal pullup.
const byte analogIn = A0;
void setup()
{
Serial.begin(115200);
pinMode(analogIn, INPUT_PULLUP);
}
void loop()
{
static unsigned long timer = 0;
unsigned long interval = 1000;
if (millis() - timer >= interval)
{
timer = millis();
Serial.println(analogRead(analogIn));
}
}
Thanks for the response! I have never heard of a voltage divider. I am very new an inexperienced so I'll take all the knowledge I can get.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.