How to Make an Automatic Nightlight LDR Circuit
by sarin51218 in Circuits > Electronics
159 Views, 3 Favorites, 0 Comments
How to Make an Automatic Nightlight LDR Circuit
Have you ever wanted to make your own nightlight? One that knows when exactly to turn on in the dark so you don't have to do it yourself? Well, here is your opportunity.
The automatic nightlight being shown in this Instructable is a light-detecting circuit (LDR) that uses a light dependent resistor to detect light and power an LED when no light is detected. It is perfect for use in the dark, and utilises other electronic components such as a potentiometer, an NPN transistor, and two resistors at 470 and 1K Ohms. To build the circuit, the best course of action that will be done in this Instructable is starting off modelling on TinkerCad, an online circuit building website, then moving forward to prototyping on a breadboard, and finally, soldering on a perfboard, as it is likely there are mistakes in the circuit if you go straight to the perfboard. You can then continue to make a case to house it and make it look nice. These steps will be outlined in the instructable.
Supplies
The components (and other supplies) needed are:
5mm LED of any colour (I used white)
470 Ohm Resistor
1K Ohm Resistor
2N2222 NPN Transistor
100K Ohm Potentiometer
9V Battery / Power Supply
Laptop (for CAD)
3D Printer
4x6cm Perfboard
Soldering Iron
Solder
Male to Male Jumper Wires
Breadboard Laptop Connector for Power
You may need extras of some of these if you mess up any of the steps.
TinkerCAD Prototyping
Starting off by prototyping the circuit online always helps to figure out how you will need to assemble the circuit both on the breadboard as well as on the final perfboard with soldering. This is by far the easiest way to plan your circuit without having to put too much effort to fix small mistakes, and you can use this as a base for your breadboard and perfboard later on.
I followed the circuit diagram to make this, but you can also use my TinkerCAD model to design your circuit as well. You can then copy this design straight onto a breadboard for testing. Since errors encountered are of no importance, it is a good learning opportunity in order to understand and experience how the circuit actually works without risk. Using the digital multimeter is also a useful tool in this context and will significantly help in understanding basic circuitry concepts especially if this is your first time.
In this model, I have attached a 9V battery to the positive and negative terminals of the breadboard, and then proceeded to have connected the first terminal of the potentiometer to the positive terminal, and the collector of the NPN transistor to the same, with the second terminal of the potentiometer linked to the terminal of the 1k ohm resistor and then that connected to the base of the transistor.
The emitter is connected to the 470 ohm resistor and that is connected to the anode of the LED.
The cathode of the LED is then connected to the negative breadboard terminal.
The first terminal of the 1k ohm resistor is then finally connected to the LDR and the other terminal of the LDR is connected to the negative terminal of the breadboard.
Keep in mind the LDR, Resistors, and the Potentiometer are all reversible, and non-polarised whereas the LED with its cathode and anode, as well as the transistor are, so they need to be connected exactly.
Transferring to Breadboard
Now that you know how the circuit works and the way to assemble it, gather most of your parts plus the jumper wires to connect the components in the same way as shown in the TinkerCAD, with the exception of the battery, which is swapped out to connect it to the laptop for power instead of the 9V battery, plugging in to the terminals of the breadboard the same.
The jumper wires may get a bit messy, so I advise you to colour code each component connection just to reduce confusion, as you will use this design as a basis for the perfboard final creation.
The breadboard works where the connection is vertical, not horizontal unless connected via a wire. Using a wire makes it easier to copy from the TinkerCAD, but on the perfboard it is recommended to use fewer wires to reduce clutter.
Perfboard Creation & Testing
The 4x6cm perfboard has the components connected slightly differently to the breadboard because there are no actual terminals, you have to make your own in a way. Most components are connected directly to each other, soldered together, but it is important to be mindful of how it is setup to ensure you don't fry the circuit due to too much current.
It is crucial that you keep your soldering neat (unlike mine) and do it with safety equipment on like goggles to not get hurt, as well as to be very cautious while using the iron because it is incredibly hot, reaching temperatures around 450 degrees celsius.
For the circuit to work correctly, each component must be soldered correctly to the other it needs to be connected to, without touching any other solder, or else the circuit will not work correctly. The best way to do this is to spread out the components effectively.
I tested using a power supply with various voltages, but it is advised to not go too high in order to not pass an excessive amount of current through the components in case you have not 1soldered the resistors properly.
Adjusting the potentiometer is required to get a bright enough light when the light sensor detects no light, so you can adjust that until it works in the needed way.
Enclosure Creation & Final Assembly
Finally, now that your circuit is complete, you are going to want to build a box or enclosure to house your circuit to make it look nicer and safeguard it from damage.
I used Autodesk Fusion to create my CAD design that conformed to the size of around 5x7cm for the base and the walls to keep the circuit inside, and a height of around 2cm. Using the in built tools I used the function to cut out a portion of around 4.5 by 6.5cm to make sure the circuit fit correctly inside and adjusted the height to ensure it does. I then added a hole in the base for the battery wires to come out of, and then made the top of the same size and holes that aligned with the LED, LDR, and the Potentiometer to ensure they are all accessible.
I 3D printed this model afterward, and placed my circuit inside it, and secured the top of the box with blu-tack for the moment to keep the circuit accessible. In the future, you may want to design your enclosure to use screws without having to drill into the frame, and you would need to make sure this is part of the CAD file, which it is not in mine at the moment. I have attached the files I created, and you may use them for reference in creating your own.
Now you can enjoy your own automatic nightlight!