Lesson 66: Controlling 4 channel relay with 4 push buttons | Arduino Step By Step Course

preview_player
Показать описание
In this lesson we learn how to control and turn ON/OFF or toggle 4 relays with 4 push buttons to turn ON/OFF an AC load like bulb or 4 DC loads.

The best thank you for me is to not to skip ads and Subscribe 🔔 to my channel, like 👍 the video It is greatly appreciated. 🔔 😊.
I will reply to all Subscriber's 🔔 questions. So make sure to Subscribe.😊 .

*** Purchase 4 channel relay from Affiliated Stores ***

*** Purchase Arduino Start Kit ***

****** Purchase Authentic Arduino Uno from ****

Download Arduino code for this video:

Use Chapters from timeline or click on the time
00:00 Introduction
01:43 Wiring explained
05:58 Code explained
11:41 Demonstration

Tutorial by Ahmad Shamshiri form Canada
****************************
****************************

Power Supply I use:

Get other projects code and learn Arduino
#robojax #robojaxArduinoCourse #robojax_

**** AFFILIATE PROGRAM ****
Рекомендации по теме
Комментарии
Автор

thank you Robojax for your precious Videos we really appreciated ..Thanks alot

abdallahkhamis
Автор

Hello,

I was going to try the code you mentioned under your video, But Unfortunately, it seems the code here is for lesson 65, and lesson 66 is not there!

Could you please let me if I am doing something not right or the code that is under lesson 66 is not for here!

Please let me know,

Thank you,

farbodser
Автор

How to make control of 4 relays with 1 button?, so pressed 1 time to on/off relay 1, pressed 2 times to on/off relay 2, pressed for 2 seconds to on/off relay 3, and finally pressed for 4 seconds to on/off relay 4. thank you

mthuda
Автор

Hello,
This Video was awesome,
I am looking for exact code with a little adjustments,
Could you please help me with this,

I need when we push one out of four Push buttons, if the others relays are on, they go off,

What adjustment do I need to add to the code?

Thank you,

farbodservati
Автор

How can i add coin acceptor here? the button will activate the relay depending on the value of pulse(coin acceptor)

OffDutyBumbero
Автор

Hello @robojax, i want to add a RTC to control the relay at the same time i can use the push button do you have a code?

mv_tv
Автор

hi there, hope you well, thank you for the great videos, excellent work.
I need a bit of assistance, i hope you can assist me
I am setting up this exact same system
4 x button
4 x Relays
I am currently using your code and it is working perfect but i need to add more logic to the code.
logic required.this is what i require

THE SYSTEM IS SET TO BE NORMALLY CLOSED
INACTIVE MEANING NOTHING MUST HAPPEN IF THOSE BUTTONS ARE PRESSED.

PRESS BUTTON A = OPEN RELAY A UNTIL PRESSED AGAIN TO CLOSE ( BUTTON B and D MUST BE INACTIVE WHEN RELAY A IS OPEN )
PRESS BUTTON B = OPEN RELAY B UNTIL PRESSED AGAIN TO CLOSE ( BUTTON A and C MUST BE INACTIVE WHEN RELAY B IS OPEN )
PRESS BUTTON C = OPEN RELAY C UNTIL PRESSED AGAIN TO CLOSE (BUTTON B AND D MUST BE INACTIVE WHEN RELAY C IS OPEN )
PRESS BUTTON D = OPEN RELAY D UNTIL PRESSED AGAIN TO CLOSE (BUTTON A AND C MUST BE INACTIVE WHEN RELAY D IS OPEN )


CURRENT CODE BEING USED
const int pushButton[] ={2, 3, 4, 5};// define push button inputs
const int relayPin[]={11, 10, 9, 8};// output pins where 4 relays will be connected
String relayNames[] ={"CH1", "CH2", "CH3", "CH4"};// Just put name for 4 relays
int pushed[] ={0, 0, 0, 0};// status of each buttons
int relayStatus[] ={LOW, LOW, LOW, LOW};// initial status of relay


void setup() {
Serial.begin(9600);// initialize serial monitor
for(int i=0; i<4; i++)
{
pinMode(pushButton[i], INPUT_PULLUP);
pinMode(relayPin[i], OUTPUT);
digitalWrite(relayPin[i], HIGH);// initial relay status to be OFF
}

}

void loop() {

for(int i=0; i<4; i++)
{
int val = digitalRead(pushButton[i]);
if(val == HIGH && relayStatus[i] == LOW){

pushed[i] = 1-pushed[i];
delay(100);
}// if

relayStatus[i] = val;

if(pushed[i] == HIGH){
Serial.print(relayNames[i]);
Serial.println(" ON");
digitalWrite(relayPin[i], LOW);

}else{
Serial.print(relayNames[i]);
Serial.println(" OFF");
digitalWrite(relayPin[i], HIGH);

}// else

}// for
Serial.println("==");
delay(100);
}// loop end

timoketimoke