top of page

RF Encoder and Decoder Controlled 4 Channel Relay

Updated: Jul 2, 2021

This tutorial to learn, One of the easiest and cheapest ways to implement wireless communication is using RF Module (Radio Frequency Module).


The transmitter circuit is built encoder HT12E Module , 433MHz RF transmitter module (TX). The receiver circuit is built around Arduino UNO board, decoder HT12D Module, 433MHz RF receiver module (RX), 4 Channel Relay Board.


Refer previous tutorial for RF encoder and decoder Interface.

Subscribe and Download code.

Components required

  • 433 MHz RF Transmitter and Receiver Module

  • HT12D Decoder Module

  • HT12E EncoderModule

  • Push Buttons (4 Nos)

  • 4 Channel Relay Module

  • Arduino Uno


Circuit Connection

Transmitter circuit

Push Button Switches S1, S2, S3 and S4 are interfaced with AD8 through AD11 of encoder HT12E Module.



Receiver circuit

Arduino Pin D2 to D5 are Connected to AD8 through AD11 of Decoder HT12D Module.

Arduino Pin D8 to D11 are Connected to LED or Relay.

Subscribe and Download code.

Subscribe and Download code.

arduino code


// WWW.DOFBOT.COM

const int Switch1 = 2, Relay1 = 8;

int state1 = 0, Relay1state=0;


const int Switch2 = 3, Relay2 = 9;

int state2 = 0, Relay2state=0;


const int Switch3 = 4, Relay3 = 10;

int state3 = 0, Relay3state=0;


const int Switch4 = 5, Relay4 = 11;

int state4 = 0, Relay4state=0;


void setup()

{

pinMode(Switch1, INPUT);

pinMode(Switch2, INPUT);

pinMode(Switch3, INPUT);

pinMode(Switch4, INPUT);

pinMode(Relay1, OUTPUT);

pinMode(Relay2, OUTPUT);

pinMode(Relay3, OUTPUT);

pinMode(Relay4, OUTPUT);

Serial.begin(9600);

}

void loop()

{

if (state1 == 0 && digitalRead(Switch1) == HIGH) {

state1 = 1;

Relay1state=!Relay1state;

}

if (state1 == 1 && digitalRead(Switch1) == LOW) {

state1 = 0;

}

digitalWrite(Relay1, Relay1state);


////

if (state2 == 0 && digitalRead(Switch2) == HIGH) {

state2 = 1;

Relay2state=!Relay2state;

}

if (state2 == 1 && digitalRead(Switch2) == LOW) {

state2 = 0;

}

digitalWrite(Relay2, Relay2state);


///

if (state3 == 0 && digitalRead(Switch3) == HIGH) {

state3 = 1;

Relay3state=!Relay3state;

}

if (state3 == 1 && digitalRead(Switch3) == LOW) {

state3 = 0;

}

digitalWrite(Relay3, Relay3state);


////

if (state4 == 0 && digitalRead(Switch4) == HIGH) {

state4 = 1;

Relay4state=!Relay4state;

}

if (state4 == 1 && digitalRead(Switch4) == LOW) {

state4 = 0;

}

digitalWrite(Relay4, Relay4state);

}

501 views0 comments
bottom of page