+88013 1284 4142

4 CHANNEL RELAY MODULE INTERFACING WITH ARDUINO UNO TUTORIAL IN ENGLISH |DOIT PROJECTS

Hi,

Let’ start our 4 channel relay module project. Things we need for our project-

  1. 4 channel relay module,
  2. An Arduino or similar board, 3. Some male jumper is about 6P

So for our project we only need these three things.

Let’s setup the hardware,

First we connect 4 jumpers from the input pin N1, N2, N3 and N4 of relay module to the pin 2, 3, 4 and 5 of the arduino. Like this.

Now we connect the ground pin to the Arduino. And vcc pin connect from the 5V of the module to the pin 5V of the arduino. After wiring complete it looks like this.

Now power on the arduino board by connecting your computer using the USB cable.

Before we work on our sketch make sure to download the arduino IDE for our specific operating system. I’ll leave a link in my description box. Where download the software and code. You can check it. Now open the downloaded code. So, this is our whole program. It is a very simple program. The code in the setup part of the program tells the arduino that pins 2, 3, 4 and 5 as output. In void loop, there are two steps.

In first  step, First two digital function about turn on and turn off the LED at a time  with two millisecond or 2 second delay between turn on and turn off. This sequence will maintain for the next 6 digital pin.

In second step, first four digital writes function about turn on the led at a time. with one thousand or one second delays On the next Four digital write function turn off the LED’s with a one thousand millisecond or one second.

Now we verify our program. You can verify it by clicking the write icon. You can see there is no error in the black box. Before upload the programs go to the tolls bar and check the board. Make sure the board selected arduino UNO and port selected on com three. Click on the upload button on the top corner and upload the program your arduino board.

After uploading the program on arduino board we connect a battery to provide power supply. After connect a battery your output will appear on the circuit. You can see that our relay module start working and LED’s start to emit.

Using this code you can also run lights, fans, and motor. You can also make a home automation project.

 

                Program/ Code

 

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin LED_BUILTIN as an output.

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

}

 

// the loop function runs over and over again forever

void loop() {

digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(2000);                       // wait for a second

digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW

delay(2000);                       // wait for a second

digitalWrite(3, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(2000);                       // wait for a second

digitalWrite(3, LOW);    // turn the LED off by making the voltage LOW

delay(2000);                       // wait for a second

digitalWrite(4, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(2000);                       // wait for a second

digitalWrite(4, LOW);    // turn the LED off by making the voltage LOW

delay(2000);                       // wait for a second

digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(2000);                       // wait for a second

digitalWrite(5, LOW);    // turn the LED off by making the voltage LOW

delay(2000);                       // wait for a second

digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW

digitalWrite(3, LOW);    // turn the LED off by making the voltage LOW

digitalWrite(4, LOW);    // turn the LED off by making the voltage LOW

digitalWrite(5, LOW);    // turn the LED off by making the voltage LOW

delay(1000);                       // wait for a second

digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)

digitalWrite(3, HIGH);   // turn the LED on (HIGH is the voltage level)

digitalWrite(4, HIGH);   // turn the LED on (HIGH is the voltage level)

digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(1000);                       // wait for a second

}

Leave a Reply

Your email address will not be published. Required fields are marked *