In many cases we need to control devices that drive larger currents like lamps, large motors or even home appliances.
Arduino became the standard as a platform for beginners and hobbyists for learning embedded development.
When we control such devices with Arduino, we need some interfacing components called relays.
Relays play an important role in interfacing between light current control circuits and larger current devices.
They simply comprise a coil that can withstand large flow of current that can drive comparably large devices. Yet this coil can be controlled using simple controlling circuits.
Here is the easiest circuit and guide to drive a relay with Arduino.
While the current required for coil control is small but it cannot be connected to Arduino directly.
Arduino ports can supply up to 35 mA only. And relay coil can draw up to 100mA which can damage Arduino board.
To overcome this situation, we use a transistor as a switch that can be used to control the coil of the relay without damaging Arduino board.
Let’s see how this is done.
Components
Relay
2N2222 transistor
Diode
Some wires
1K ohm resistor
Circuit
The circuit is very simple. You connect Arduino digital port with the transistor base through a resistor to act as a switch.
The relay is controlled by the transistor Collector-Emitter CE voltage to be switched ON and OFF.
The LED is connected for indication.
The diode is connected to protect the transistor from induced EMF during relay switching.
Arduino Code
Just as simply as you write a code for blinking an LED with Arduino, you can use the same way to control the relay.