Introduction: How to Control the Relay Shield With Arduino. (MR007-002.1)

Picture of How to Control the Relay Shield With Arduino. (MR007-002.1)

Hey there! Here I'll try to show you an easy way to start messing with your relay shield.

Step 1: Things You'll Need.

Things you will need:
Electrical parts
: Arduino UNO
: Relay shield (MR007-002.1)
: Power supply (2 - 12V DC, 2 Amps)
: Lamp (220V AC, 60W)
Tools
: Soldering iron (220 V AC, 40W)
: Plier
: Electrical tape
: Screw driver
: Scissor
: Wires
: Socket
: Heat shrink
: Matches/Lighter
: Bulb holder

Step 2: Grab All Your Parts.

Picture of Grab All Your Parts.

You. not necessarily need all these just to learn to control your relay shield. Just your Arduino microcontroller with the relay shield is enough. The 4 relays are connected to the digital pins 5, 6, 7 and 8 respectrively. But before you rush and upload a code to set all these badboys in the HIGH mode, know that Arduino, atleast UNO, cannot by its own power them up. And it is why you need to supply the relay shield +12V DC in the proper place put behind the relays (near the edge of the shield). Care however, to upload your code after setting the switch to "Prog" mode and not on "Run" mode. This little switch is also there on the shield and shall be clear to see.

Step 3: Plug Your Shield on Top of Your Arduino and Make Sure All the Pins Line Up.

Picture of Plug Your Shield on Top of Your Arduino and Make Sure All the Pins Line Up.

Plug in the source from your powersupply or battery if you have any. Before you rush and trun your powersupply on, know that the Arduino has to be powered on first (for some safety reason).

Step 4: The

Picture of The

The code is really simple and feel absolutely free to change this one.
It will set all the pins as output then turns them on and off with a one second delay in between.


void setup()
{
for(int a = 5; a {
pinMode(a, OUTPUT);
}
}
void loop()
{
for(int a = 5; a {
digitalWrite(a, HIGH);
delay(1000);
digitalWrite(a, LOW);
delay(1000);
}
}

Upload your code to Arduino, and here them relays click! ;)

Done yet? Well if your intention is just to know how they work, then yeah. But if you want to turn your bedroom light with just a snap, stick around. :p

Step 5: Simply, Just Do As Shown in the Pictures Below.

Picture of Simply, Just Do As Shown in the Pictures Below.

If the pics weren't that clear, what I did was just leave the two outputs of the light that wouldhave been replaced by your switch and connect them in all the proper way, solder things and all. (Simple stuff)

Step 6: Finally You Just Have to Change Your

Picture of Finally You Just Have to Change Your

I here am not going to put the exact code as your intentions may differ. The idea is to get some input via your pins (digital or analog), and then set one of your relays HIGH.

void setup()
{
pinMode(5, OUTPUT);
}
void loop()
{
if( yourConditionHere)
{
digitalWrite(5, HIGH);
}
else
{
digitalWrite(5, LOW);
}
}

Yep! Simple.

Cheers! ;)

Let me know if you had difficulties what soever. Also I would appreciate it if you let me know what amazing things you did with the relay shield.

#1aku
Take care. ;)

Step 7:

Step 8:

Step 9:

Step 10:

Comments

DIY Hacks and How Tos (author)2016-09-24

Nice. Relay shields are by far the most useful shield that you can get for an Arduino.

About This Instructable

444views

9favorites

License:

More by 1aku:How to Control the Relay Shield With Arduino. (MR007-002.1)
Add instructable to: