# Darkness Detector Help

#### chefman2006

Joined Sep 18, 2023
5
Hey all,

Very sorry if this has been answered. Promise I’ve tried to search. I’ve watched what has to be a million videos and read an equal number of forums, but can’t seem to get this working.

I’m just trying to make a simple darkness detector circuit. I’m just a tinkerer so I don’t know a ton about the math behind all of this.

Using a generic LDR and an S8050. Picture included. I’ve tried changing resistance to the base both higher and lower and I still just get a light detector (brighter with light; dimmer with dark).

Any help would be greatly appreciated.

#### MisterBill2

Joined Jan 23, 2018
16,495
Welcome to AAC!
Two things usually help toward getting useful solutions to problems, the first one being to make a clear statement as to what the ultimate goal is, rather than just asking for an answer to whatever the question may be.
And the second thing that helps is an actual circuit schematic instead of a picture of an assembly. M
Certainly that is possible, but much simpler isany of the folks here always ask for a circuit drawing before they can even think about a solution.

I am going to guess that what you seek is a circuit that switches on an LED when darkness (the absence of light) is present. But the opposite is much simpler, which is switching off something, such as a light, when light is sensed.

#### MrChips

Joined Oct 2, 2009
29,809
We cannot help you without seeing the circuit schematic, part numbers, part values.

What is the part number of the transistor? Is it NPN or PNP or something else?
What are the resistance values?
What is the resistance of the LDR in light and dark?
Has the LED been tested and wired correctly?

As you can see, the devil is in the details.

#### chefman2006

Joined Sep 18, 2023
5
We cannot help you without seeing the circuit schematic, part numbers, part values.

What is the part number of the transistor? Is it NPN or PNP or something else?
What are the resistance values?
What is the resistance of the LDR in light and dark?
Has the LED been tested and wired correctly?

As you can see, the devil is in the details.

Apologies for the confusion, I thought the original picture would suffice. Here’s the circuit as I understand it. The primary difference being that the transistor I’m using is an S8050 (as mentioned in the original post). Does this provide the details you need?

Last edited by a moderator:

#### ericgibbs

Joined Jan 29, 2010
18,216
Hi chef,
With that simple circuit, you will not get the 'snap' action at the light/dark boundary, it will always be brighter/dimmer.
Do you have any amplifier or comparator IC's on the bench?
E

xox

#### chefman2006

Joined Sep 18, 2023
5
Hi chef,
With that simple circuit, you will not get the 'snap' action at the light/dark boundary, it will always be brighter/dimmer.
Do you have any amplifier or comparator IC's on the bench?
E
That’s a good point. I would like the snap eventually. The problem right now is that the circuit still acts like the LED is only connected to an LDR. Brighter environment makes the LED brighter and vice versa. I’m at a loss.

#### ericgibbs

Joined Jan 29, 2010
18,216
Hi chef,
Do you have any details of the LDR, or a part number?
E

#### chefman2006

Joined Sep 18, 2023
5
Hi chef,
Do you have any details of the LDR, or a part number?
E
Package says GM5539. Google takes me to a link for Amazon when I type it in so I’m not sure if that’s an official part number of not.

#### ericgibbs

Joined Jan 29, 2010
18,216
Hi,
This simulation shows how your circuit works, note the Xaxis range for the LDR is only 3k5 Dark, 4k8 Light, about a 1k change.

I am using a 9V battery, what voltage is yours?
E

#### Ya’akov

Joined Jan 27, 2019
8,504
Have you measured the resistance of the LDR in bright and dark conditions?

#### ericgibbs

Joined Jan 29, 2010
18,216
Hi chef,
This is the GM5539 datasheet clip.
Note the LDR resistance range.
E

Update:
Your simple circuit cannot work with that LDR type.

#### Alec_t

Joined Sep 17, 2013
14,005
Brighter environment makes the LED brighter and vice versa
The schematic is correct in principle, but it looks like you need to swap the positions of the LDR and its associated resistor on your breadboard to match the schematic.

#### chefman2006

Joined Sep 18, 2023
5
Hi chef,
This is the GM5539 datasheet clip.
Note the LDR resistance range.
E

Update:
Your simple circuit cannot work with that LDR type.

View attachment 303113
Well at least it’s a relief that I’m not just an idiot altogether. Is there an LDR you could recommend for use? I am using a 9v battery.

#### ericgibbs

Joined Jan 29, 2010
18,216
Hi chef,
This GM5506 is one option, gives a slightly better control over he light/dark setting with the Pot.
E

#### MisterBill2

Joined Jan 23, 2018
16,495
From the description of the function, that the LED gets brighter with light on the photo-resistor getting brighter, the simple explanation would be that the transistor is a PNP with the emitter and collector reversed from what the drawing in post #4 shows. As the LDR resistance would drop, the base current would rise.
And given that the number for the transistor does not tell me anything, that might be the case.