Relay tutorial

One of the modules that are used to work with high voltages, is the Relay. On the front it has three ports: NO, COM and NC. It works like a regular switch: when triggered, it closes the connection with the NO (Normally Opened) and opens the one with the NC (Normally Closed). For example, if we connect two wires, one on the NO and one on the COM, they’re not connected until we give the .on() command to the relay. If we put them on COM and NC, they are always connected until the .on() command is given.

For our tutorial, as a practical demonstration, we are going to make a relay socket that we can control from our TinkerKit!.

For that we need just a regular extension cable and a pair of scissors.

Start by peeling a small portion of the cable in order to show the inside wires. There should be two or three cables, in our part of the world they are blue, brown and yellow.


What we are going to do is opening the circuit by cutting one of these wires and plug it into the relay, so that we can control it. If you have just two wires, cut any of the two. If you have three of them, refer to the color code of your country, spot the ground and don’t cut it, instead cut one of the other two.
Here in Italy the ground is green and yellow, so we decided to cut the blue.

Now peel a small portion of rubber from each of the two parts of the wire, in order to show the metal inside. In our case we have a group of tiny copper wires inside, so we twisted them to make it easier to manipulate.

Now put one wire inside the NO and one into the COM

Connect the relay to an output port of your TinkerKit!, we used the O0.

Now let’s connect something to our socket, we decide to use this beautiful spring lamp.

Plug it into the socket

Now let’s write a test code, we can make the lamp blink exactly like an LED by using the on and off methods:

#include <TinkerKit.h>

TKRelay relay(O0);

void setup() {

}

void loop() {
  
  relay.on();
  delay(1000);
  relay.off();
  delay(1000);
  
}

After uploading it into the board, you should hear a click every second. That’s because inside the relay there’s a spring that jumps every time we switch it.
The last thing we do is plugging the other end of the socket into our wall plug, to turn on our light.

From now on, don’t touch the relay module until you are sure that there’s no more high voltage electricity flowing through it. Considering the importance of this, let’s write it again in full caps:

DON’T TOUCH THE RELAY MODULE UNLESS YOU HAVE PULLED THE PLUG FROM THE POWER AND YOU’RE SURE THERE’S NO HIGH-VOLTAGE ELECTRICITY FLOWING THROUGH IT

If everything went fine and you’re still alive, you should see a blinking lamp:

  1. March 4, 2013

    Gabriele

    Fantastic!!!
    Sinceramente ero un po’ dubbioso all’ inizio, poi ho provato e…. fantastico :))

  2. March 24, 2013

    Callum

    NO NO NO!! Dangerous, very dangerous! IF you are going to wire this, wire it over the live cable! Not the Neutral! Means that the there is 100% no power going to the device. You may wish to stress this before someone gets hurt…

  3. June 18, 2013

    saru

    Brown – live
    Blue – neutral

  4. September 14, 2013

    Niclas

    you dont now witch of them is the live cabel ,its depend howe you plugg in the contact.
    brown can be neutral and blue live

Leave a comment

  1. Tout savoir pour commander une alimentation 220 volts | blinkblinkcommunity01-19-13

High Voltage Lessons: