![]() ![]() In our switch statement, we set the relay pin to HIGH to close the relay circuit which will turn on the light bulb and when minus button on the remote is pressed, we set the relay pin to LOW to open the relay circuit which will turn off the light bulb. So we decode the buttons and use it in our switch statement in the loop function. In my project, I wanted the plus sign button to turn on the light, and the minus sign button to turn off the light. We first want to see the encoded form of the buttons on the remote. Click here to check out my other blog to learn about an IR receiver if you don’t know how it works. Then we put an IR receiver for the remote. With this configuration the circuit is broken and the current is not flowing unless you send a signal from the Arduino to close the circuit. Then we put one wire into the NO (normally open) pin of the relay, and the other wire into the COM (common) pin of the relay. We take a wire from the light bulb and cut it so that we have two separate wires just like it is shown in the picture above. The picture above shows the completed circuit for the remote control light bulb using the relay. Without the jumper cap, you need to provide a separate 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. With the jumper cap on, the VCC and JD-VCC pins are connected. The JD-VCC pin powers the relay’s electromagnet. ![]() As you can see, the VCC and the JD-VCC is covered with a jumper cap. The set of three pins has GND, VCC, and JD-VCC. The set of four pins has VCC which is for power, GND, which is for ground, and IN1 and IN2 which is the pin that controls the relay switch to turn high voltage device on or off. This side has a set of four pins and a set of three pins. Now let’s talk about the side that connects to the Arduino. If you just want to light up a lamp occasionally, it is better to use a normally-open circuit configuration. NO (Normally Open): The normally open configuration works the other way around: the relay is always open, so this means that the circuit is broken and the current is not flowing unless you send a signal from the Arduino to close the circuit (this is the configuration we will use).NC (Normally Closed): The normally closed configuration is used when you want the relay to be closed by default, this means that the current is flowing unless you send a signal from the Arduino to open the circuit.The common pin (COM), normally open pin (NO), and normally closed pin (NC). The side that controls the high voltage device has 3 pins. One connects to the high voltage device and the other side connects to the Arduino. There are other models with 1, 4, and 8 channels. This means it can control two high voltage devices. The following code will allow you to use a button to control a relay with the Arduino.In this tutorial we will learn how to control high voltage devices using a relay module.Ī relay is a switch which is electrically operated by an electromagnet. You have been warned! Code for Using a Button to Control a Relay If you don’t have experience with it, we recommend you do not do this project or that you seek additional expert help. Warning: Mains voltage can seriously injure or even kill you. ![]() In this wiring example, we’re showing how you could control a 110v/220v light bulb using an Arduino with a relay module. Next up in our mission to control a relay with a button, it is time to wire everything up on the breadboard. Wiring Diagram : Control a Relay with a Button If you use them, they cost you nothing, but we may get a small commission that helps us keep building awesome content like this. Some of these links may be affiliate links. ![]() Here’s a handy parts list for this project. For example, we can control traditional incandescent light bulbs, a high power motor, a servo actuator, or even a regular household appliances such as a coffee pot or a vacuum cleaner. We’re going to cover that in the next tutorial! Just know that when the Arduino activates it, it works like a switch: turning some other device On or Off.īy using a relay, we can control all kinds of high voltage or high current devices from the Arduino. RELATED: Control a Relay with a Light Sensorĭon’t worry too much about how a relay works. This is a very similar tutorial to our button LED control tutorial, but with a relay! The main difference being that a relay will allow you to control something of higher voltage than the Arduino can control directly. In this Arduino tutorial, we’re going to learn how to control a relay with a button. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |