Header Ads

Header ADS

4 channel relay module interfacing with Arduino Uno Tutorial in English |Doit projects

4 channel relay module interfacing with Arduino Uno Tutorial in English |Doit projects


Visit this link to watch the practical video on this project: 

https://youtu.be/Tjh-cnH4klo



Hi,  today in this blog I will teach you how you can create a project with a 4 channel relay module.

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 6 is


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 the 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 connects from the 5V of the module to the pin 5V of the Arduino.


After wiring complete, 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 the first step, the First two digital functions 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 pins.
In the second step, the 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 one thousand milliseconds or one second.

 Now we verify our program. You can verify it by clicking the write icon. You can see there are no errors in the black box. before upload, the program, 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 to your Arduino board.
After uploading the program on the Arduino board we connect a battery to provide the power supply.

After connecting a battery Your output will appear on the circuit. You can see that our relay module starts 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               
}

2 comments:

  1. Hello there, this is amazing blog i really appriciated. thats great you are good writer
    Click here
    Click here
    Click here
    Click here
    Click here
    Click here
    Click here
    Click here
    Thank you


    ReplyDelete
  2. Your article was very instructive and informative. I read articles for gaining knowledge and I like to write articles a lot. If you want, you can see how I have best custom writing here.

    ReplyDelete

Theme images by Bim. Powered by Blogger.