Really what the code does is that it reads the value that comes from LDR and then compares it to the parameters we have set. Now the LDR would have not effect on the light bulb turning on or off without this code informing the Arduino on how it should react to the information the LDR sends it and how it should communicate with the light bulb. Now when you start the power supply your light bulb should turn on, if it does not please review all the steps carefully. Now using a red wire, connect the positive socket of the power supply to the Terminal 2 socket of the light bulb. Use a black wire and connect one end of it to the negative socket of the power source and the other end to the breadboard column which has the Terminal 1 pin of the SPDT relay connected to it. The red one is for supplying power while the black one is used for ground. The power source should have two sockets, a positive one coloured red and a negative one coloured black. However, if you do not want to switch and are content with one power source, then that is completely fine as well. I will explain how to switch between the power sources using a slide switch later on in the instructable. The power source I am using for the circuit is the 5V power supply, however, you could also use the three AAA batteries as well, they both work fine with the main light bulb. Let's leave the Terminal 2 socket of the light bulb empty for now and move on to the power source. To start wiring, connect one end of a wire to the Terminal 1 socket of the light bulb, and the other end to the breadboard column in which the Terminal 7 pin of the SPDT relay is connected to. First, let us set up the light bulb, the light bulb has two sockets called much like the LDR, Terminal 1 and Terminal 2. Now it is time to set up the core component of the circuit and the project, the light bulb and its power source. Lastly, connect a wire going from the 'A0' socket of the Arduino to the column of the breadboard where the Terminal 2 leg of the LDR is placed. Connect one end of a wire into the column the second end of the resistor is placed, and the other end of the wire into the power rail on the breadboard. Then, connect one leg of the 1000 Ohm resistor to the column in which the Terminal 2 leg of the LDR is placed, and the other in any other column in the breadboard. Connect a black wire from the column in which the Terminal 1 leg of the LDR is positioned to the ground rail of the breadboard. Once the wiring is complete, place the LDR on to the breadboard, make sure the legs are in two different columns of the breadboard. The colours of the wire don't really influence the circuit in any way, they just allow your circuit to look more organized and easier to follow. Then attach a black coloured wire going from the GND socket of the Arduino referred to as the ground socket into the ground rail of the breadboard marked with a black '-' symbol. First, attach a red coloured wire going from the 5V socket of the Arduino to the power rail marked with a red '+' sign. The LDR has two legs, the first one being called Terminal 1, and the other being Terminal 2. However, if you wish to physically create this circuit, you could do so by using this same instructable as all the steps done in TinkerCAD can also be executed with a real circuit board and wiring, as TinkerCAD follows the same logic as a physical circuit.įirst, we are gonna set up the Light Dependent Resistor (LDR) as that is the main component which is gonna sense for light and send the order through the Arduino to the light bulb to power it on. Now I will be creating this circuit within TinkerCAD, a free-to-use online modelling program that allows you to create circuits electronically. However, this component is completely optional, if you wish to just include one power source and have your lamp run off of that, then you are free to do so. In this circuit, I am also including a slide switch which would allow one to easily switch between which power source the light bulb receives its energy from. Then when the LDR detects an adequate amount of light in the room, it would instruct the light bulb to stop shining light as the room is dark no more. Essentially the way the lamp would work is that when the LDR (Light Dependent Resistor) attached to the lamps circuit detects darkness in its immediate area, it would command the light bulb to turn on through the help of the Arduino microcontroller also apart of the circuit. This instructable will show you how you can create a lamp that will turn on automatically when it gets too dark within the room its located.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |