How to Use Relays
(If you want to order relays, skip down to the section titled “Ordering relays”)
What are they?
Relays are on and off switches for electronics.
Why are they significant?
Higher powered circuits can ruin lower powered components. For example, powering a large motor with an Arduino board will not end well for the Arduino. The relay allows higher powered components to interact with lower powered components without the risk of damage.
Before following these instructions, you should know about open and closed circuits. You should also be able to understand a basic electrical schematic.
Introduction to the pins:
– this pin should be connected to +5v at all times
– this pin should be connected to ground at all times
– IN is the pin that switches on and off the relay. If it receives 0v, the relay is in its normal state. If it receives +5v, it is not in its normal state.
– IN is sometimes called “Digital Pin” or just “D.”
– The COM pin will always be used in a circuit; it is the pin that is measured from.
– NC stands for Normally Closed. This is the pin that will form a closed circuit with COM when the relay is in its normal state.
– NO stands for Normally Open. This is the pin will form an open circuit with COM when the relay.
Examples of use:
Let’s say you have a gigantic light bulb (or any electronic component that uses a lot of power) and you need to be able to switch it on and off with an Arduino. The big light bulb needs a big battery to power it, but that amount of power would burn the Arduino to a crisp. The solution is to use a relay.
As you can see, the +5v pin on the Arduino is attached to the VCC pin on the relay and the GND pin on the Arduino is connected to the GND pin on the relay. The IN pin on the relay is connected to the digital pin on the Arduino that will control the circuit.
Because Circuit 2 is connected to the NC pin, the circuit will be closed and the lightbulb will be on when the digital pin on the Arduino is off (the “normal” state). The lightbulb will be off when the digital pin on the Arduino is on. If it was connected to the NO pin, the opposite would happen.
Testing a relay:
To test your relay, use the blink sketch. Attach VCC to +5v, GND to ground, and IN to whichever pin is blinking (13, usually). If you hear the relay clicking on and off every second, you are good to go!
– If your relay stops working with your program, always go back to the blink sketch. If that sketch works then there must be something wrong with your program.
– Instead of plugging VCC, GND, and IN pin using male wires, you can put all three of those pins into the three male wires on the arduino board usually located right next to the digital pins. Just make sure everything is lined up correctly.
Here’s just a list of resources which may help you with relays. Feel free to add.
Here is the type of relay we used:
If you don’t get that exact type, try to find something similar—nothing too fancy is necessary.
Also you can either get a single relay per unit or dual relay module (same thing except 2 relays are there per unit)