Hello guys ,
I have a relay ( SKU : 19-RLY-00001 ) from http://grobotronics.com/relay-module-1-channel.html?currency=USD&sl=en and i would like to help me with the connections on both sides !
Which cable i connect in each hole and i have to program it as a digital switch ?
Like :
if (that)
{switchstate == LOW
}
else
{switchstate == HIGH
}
There is no mention of a driver transistor for the relay. You cannot connect a relay directly to the Arduino pins unless you want to risk damaging the Arduino.
To connect the output of the relay to control you load, you need to use the normally open contacts only. These are used as a simple switch in series between the power and the load with the other side of the load going back to the other side of the power.
YOU HAVE NOT MENTIONED WHAT YOU ARE GOING TO CONTROL SO PLEASE READ THE FOLLOWING.
MAINS POWER IS LETHAL. UNLESS YOU KNOW WHAT YOU ARE DOING, DON'T DO IT.
IF YOU INSIST ON DOING IT, TRY THE SWITCHING ON A LOW VOLTAGE FIRST (Use a battery and LED with a resistor)
REMEMBER THAT THE BOTTOM OF THE BOARD WILL ALSO BE LIVE ON THE PCB TRACKS.
On the other side you have NC & NO. That stands for "normally open" and "normally closed," so if you wire your output up so that you're on the N.O. side, when you say switchState = HIGH, the contacts close and you connect a circuit (like turning on a light). Then, if you wire it so that the two wires are on the N.C. side, when you say switchState = HIGH, you make a open the circuit, and turn whatever you had connected to the relay off.
The spec sheet on the relay pretty well tells how to use it. One thing that immediately caught my eye and that is that it requires 85ma so you cannot drive it directly from an Arduino board.
Power to the relay should come from an external source, should not power it from your Arduino.
Both Relay module and Arduino should have a common ground.
A digital output from your Arduino should connect to 'S' pin, if input to S is high then Relay will get activated, low will deactivate it.
Attached the fritzing diagram shows how to connect a Relay to Arduino. In the diagram I used a 3.7v battery as a power source, you should connect a 12v source. Also I connected the power directly to Arduino VIN. You can use a USB to power it, if used USB then connect only GND to input DC GND.