Vinz68 / NeoPixel-Stair

Stair LedLights, using NeoPixel Ledstrips and an Arduino
9 stars 1 forks source link

LDR not working #1

Closed zwollerob closed 4 years ago

zwollerob commented 4 years ago

Hello,

I have used your script but the LDR is not working. What is wrong? In the Console I see the daytime limit so the stairs does not work. But when I put my finger on the LDR there are no messages anymore but the PIR is not working. So the stairs does not go on...

The code used is EXACT the same as your...

Vinz68 commented 4 years ago

Hello zwolerob,

Maybe the needed value for the LDR is different or there is a problem in the wiring (so the value might not be read correctly from the AO input).

One of the things you could do to verify this and see why it is not working is to uncomment line 165

So change line 165 from:

// Serial.println(LDRValue); 

into: Serial.println(LDRValue);

In this way you will see the value of the LDR sensor. See if the value changes in different light conditions, and determine the value when you want the PIR to be operational. It might need a bit finetuning.

Hope you can find the problem. If not then do not hesitate to contact me.

Best regards, Vincent.

zwollerob commented 4 years ago

the wiring is correct. I tested the LDR sensor on an Arduino Nano the value goes up when more light and goes down whit less light...

De PIR sensors also work good. because when disabling LDR they work like a charm :)

will look further in to it. but i am sure the ldr sensor and PIR are good ;)

zwollerob commented 4 years ago

well even tried an other arduino board... same issue... value changes but PIR not responding... you have also a 10k ohm resistor on your LDR?

Vinz68 commented 4 years ago

what LDRValues do you see in the Tools/Serial monitor ? Do you see this output line in the serial monitor ? "LDR detected Daylight according to LDRThreshold configuration"

Vinz68 commented 4 years ago

It is essential to know which values your LDR gives ; since above a threshold it is considered to be daylight and PIR digital inputs will not be read in ; that is in this part of the code: if (LDRValue >= LDRThreshold)

The LDRThreshold is set in the begin of the script to 600 ; so only below 600 it is considered to be dark and only then the PIR Sensors will be activated. This LDRThreshold value might need to be changed for your LDR.

Also this scripts works on my frieds stairs; but he has an Arduino Mega. I have not tested it on an Uno yet. I will see if I have a LDR/PIR in my storage, if so then I will give it a try on the Uno as well.

Note that the LedStrips needs to be powered via an external power supply since the Arduino boards cannot deliver the needed amperes.

Hope this info helps ; if not contact me.