Circuit works with power supply module, but not when connected directly with a battery?

I am fairly new to electronics and circuitry, and I ran into a small problem while trying to make a simple circuit on my breadboard. The objective is for the LED to turn off when the photoresitor receives light and turn on when there is no light. The circuit worked fine with the arduino power supply module until I tried to connect it directly to a 3V battery pack. I tried 6V and it did not work either. The problem is that the LED does not seem to be affected by the photo resistor when a battery is connected (always being on). Here is a picture of the circuit when the light is on with the power module:

Here is a picture of the circuit when the light is on with the batteries:

EDIT:

This is the best schematic (first one) that I could make. I apologize if it is a bit confusing.

• Welcome to EE SE. Would you mind posting an actual circuit schematic as per electronics.stackexchange.com/questions/28251/… – jramsay42 Feb 6 '18 at 5:03
• what is arduino power supply module? – jsotola Feb 6 '18 at 5:19
• Are you using a single transistor circuit? If so, where did you find it? Otherwise, are you using a program with the Arduino which uses an ADC to read the value on the LDR and then activate the LED based on a software decision? You need to write a lot more about what you are doing, and how you are doing it. A picture is nice. It says you are actually making something with wires and so on. But it does not really help us help you. – jonk Feb 6 '18 at 5:29
• @jsotola It is a module that takes in a 9V battery and outputs 5V into the breadboard. – Gilbert. F Feb 6 '18 at 5:31
• @jonk I am using a single NPN transistor (PN2222) that came with an Arduino kit I purchased a while back. I am not using any Arduino programs. – Gilbert. F Feb 6 '18 at 5:33

It's a very common problem. Mostly, because it is very difficult to set up a single transistor to provide hysteresis. Hysteresis is a way of forcing a circuit to stay off until a certain value is reached, but once it is turned on, then a different certain value must be reached to turn it back off. If you didn't do that, then you might have "flickering" behavior or else just a kind of non-linear dimming behavior, rather than a clean on/off behavior.

Here's a two-BJT circuit you can try with $6\:\text{V}$. (It would also work with a $9\:\text{V}$ battery if you want to use one of those, instead.) Use either the left or right side, depending on the type of BJT you have more of.

simulate this circuit – Schematic created using CircuitLab

The two BJTs are arranged in a special kind of "comparator" called a "diff-pair" or "long-tailed differential pair." It's a very common arrangement. The left side uses a simple voltage divider that includes the LDR. The right side uses a resistor divider, as well. But in this case there is some "feedback" used from the collector of $Q_1$ to change the threshold based upon the on/off state of the circuit. There are really two outputs for this circuit; one which is used for the feedback which is the collector of $Q_1$ and the other which is used to drive the LED, itself (the collector of $Q_2$.)

If you make $R_2$ a little smaller, the LED will be a little brighter. If you make $R_1$ a little larger or smaller (percentage wise), then you will change the amount of light needed for a transition. The values of $R_3$, $R_4$, $R_5$ can also be adjusted somewhat. You should feel free to change their values around a little to see how it affects the results. There shouldn't be any harm to the circuit or the LED if you don't change them too much.

If you don't have access to a second BJT, you should definitely buy another. In fact, you should get a few PNP and NPN devices to play with. They are not expensive devices.

simulate this circuit – Schematic created using CircuitLab

I added 100K to effectively shunt some of the light current to help switch it off. YOu can play with this value between 20k and open circuit.

Otherwise this is what I see in your 1st photo. (minus R1)

If your had 4.5V then you would be adding 1.2V /12mA = 100 ohm in series.. If you had 6 V then you would be adding more resistance to limit LED current... Right now the LED voltage almost matches the 3V battery but not quite., 6V would burn it out the transistor.( as in hot)

With 3V vs 3.3V it makes a huge difference in LED current as this is right at the LED voltage threshold. ( so 3V is not quite enough and more than 3.3V needs a series R with the LED to limit current Like 3,7V LiPo adds 0.4V/10mA= 40 Ohms.

You can choose up to 20mA for long term and 30mA for short term for 5mm LEDs