Hi all, I am brand new to this site, and getting familiar with Arduino and WS2812 led light strips.
have a problem that I can not figure out , attached below is my sketch and trying to get my LDR to work , I have spent hours on this , almost to give up. I changed the value from 0 to 400 to 1000 still nothing, am I missing something in the code. thank you
have ground on LDR going to ground on Arduino, on the power side wire going to the A0 Analog in , of the Arduino, this same wire is split up , and other half going to the power source with a 270 ohm resistor.
The 270 Ohm resistor is way to low in value. I sometimes use the internal pull-up (30K to 50K). Or 10K might be reasonable. Depends on the LDR and response that you want from the LDR.
To use the internal pull-up enable it with, for example, pinMode(A0, INPUT_PULLUP).
Then write a short sketch with only the LDR connected and print the ADC values to serial monitor confirm that it works and play with the resistor value to get the response that you need.
Do you want the LDR to measure light levels or just give a binary bright vs dark indication?
I use LDRs to detect when a model train is in position. I use a 68k (or more?) resistor in the voltage divider and use digitalRead() to sense the state of the LDR.