![]() This seems pretty straight forward with lots of guides on the net where you use the arduino to trigger a relay. Relay pin is controlled with D8.I am just learning how to use an arduino and as a test project wanted to set up a wifi garage door controller. Warning: you shouldn’t upload new code while your Arduino is connected to the relay. You can use the preceding links or go directly to /tools to find all the parts for your projects at the best price!Ĭopy the following code to your Arduino IDE and upload it to your Arduino board. Arduino UNO – read Best Arduino Starter Kits.Here’s the needed parts for this example: If you’re not 100% sure what you are doing, do yourself a favor and don’t touch anything. This is a serious topic, and we want you to be safe. Warning: when you are making projects that are connected to mains voltage, you really need to know what you are doing, otherwise you may shock yourself. Please read the safety warning below carefully. Safety warningīefore proceeding with this project, I want to let you know that you’re dealing with mains voltage. To control the lamp with mains voltage we’ll use a relay module in normally-open configuration. If you are not familiar with the PIR motion sensor, you can read the following post: Motion will be detected using a PIR motion sensor. A lamp lights up for 10 seconds every time motion is detected. In this example, we create a motion sensitive lamp. Otherwise, you don’t need to connect it)Įxample: Controlling a Lamp with a Relay Module and PIR Motion Sensor IN2: controls the second relay (it should be connected to an Arduino digital pin if you are using this second relay. ![]() IN1: controls the first relay (it will be connected to an Arduino digital pin).The connections between the relay module and the Arduino are really simple: That configuration physically isolates the relays from the Arduino with the module’s built-in optocoupler. Without the jumper cap, you need to provide an independent power source to power up the relay’s electromagnet through the JD-VCC pin. That means the relay electromagnet is directly powered from the Arduino’s power pin, so the relay module and the Arduino circuits are not physically isolated from each other (this is the configuration we’ll use). With the jumper cap on, the VCC and JD-VCC pins are connected. The jumper cap allows you to choose whether the circuit is physically connected to the Arduino circuit or not, and you can choose to have it on or not. Note: notice that the module has a jumper cap connecting the VCC and JD-VCC pins the one shown here is blue, but yours may be a different color. The JD-VCC pin powers the electromagnet of the relay. The second set of pins consists of GND, VCC, and JD-VCC pins. The set at the right consists of VCC and GND to power up the module, and input 1 ( IN1) and input 2 ( IN2) to control the bottom and top relays, respectively. ![]() The low-voltage side has a set of four pins and a set of three pins. If you just want to light up a lamp occasionally, it is better to use a normally-open circuit configuration. ![]()
0 Comments
Leave a Reply. |