Ir remote control relays using node mcu board with manual touch button also

Hello Everyone,
I am a beginner at coding, if I am doing minor mistake please forgive me ,

i am trying to control my 4 channel relay module with node MCU board with manually by touch the button, and remote also,

Here is My coding and complaining result zero, but my board and function not working,

#include <IRrecv.h>
#include <ESP8266WiFi.h>

uint16_t RECV_PIN = D10;

IRrecv irrecv(RECV_PIN);

decode_results results;

int load1, load2, load3, load4, power;
int flag1, flag2, flag3, flag4, flag5;
int timer=0;

#define Relay1 16 // Load1 Pin Out
#define Relay2 5 // Load2 Pin Out
#define Relay3 4 // Load3 Pin Out
#define Relay4 0 // Load4 Pin Out

#define touch1 2 // Light Button Pin in
#define touch2 14 // Lamp Button Pin in 
#define touch3 12 // Socket Button Pin in 
#define touch4 13 // Fan Button Pin in
#define touch5 15 // Power Button Pin in

void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver

pinMode(touch1, INPUT);
pinMode(touch2, INPUT);
pinMode(touch3, INPUT);
pinMode(touch4, INPUT);
pinMode(touch5, INPUT);
 

pinMode(Relay1, OUTPUT); digitalWrite(Relay1, 1); 
pinMode(Relay2, OUTPUT); digitalWrite(Relay2, 1); 
pinMode(Relay3, OUTPUT); digitalWrite(Relay3, 1); 
pinMode(Relay4, OUTPUT); digitalWrite(Relay4, 1); 
}

void loop() {

if(digitalRead(touch1)==1){
if(flag1==0){flag1=1; 
load1 = !load1; 
 digitalWrite(Relay1, HIGH) ;
 }
}else{flag1=0;
digitalWrite(Relay1, LOW) ;
}

if(digitalRead(touch2)==1){ 
if(flag2==0){flag2=1; 
load2 = !load2; 
digitalWrite(Relay2, HIGH) ;
 }
}else{flag2=0;
digitalWrite(Relay2, LOW) ;
}

if(digitalRead(touch3)==1){ 
if(flag3==0){flag3=1; 
load3 = !load3;
digitalWrite(Relay3, HIGH) ; 
 }
}else{flag3=0;
digitalWrite(Relay3, LOW) ;}

if(digitalRead(touch4)==1){ 
if(flag4==0){flag4=1; 
load4 = !load4; 
digitalWrite(Relay4, HIGH) ;
 }
}else{flag4=0;
digitalWrite(Relay4, LOW) ;
}

if(digitalRead(touch5)==1){ 
if(flag5==0){flag5=1; 
power = !power;
digitalWrite(Relay1, HIGH) ;
digitalWrite(Relay2, HIGH) ;
digitalWrite(Relay3, HIGH) ;
digitalWrite(Relay4, HIGH) ; 
 }
}else{flag5=0;
digitalWrite(Relay1, LOW) ;
digitalWrite(Relay2, LOW) ;
digitalWrite(Relay3, LOW) ;
digitalWrite(Relay4, LOW) ;
}


if(irrecv.decode(&results)){
 digitalWrite(results.value,HEX);
  
     if(results.value==0x1FE50AF){ // For Load1 On  
load1 = 1;   
}
else if(results.value==0x1FE50AF){ // For Load1 Off 
load1 = 0; 
}

else if(results.value==0x1FED827){ // For Load2 On 
load2 = 1; 

}
else if(results.value==0x1FED827){ // For Load2 Off 
load2 = 0; 
}

else if(results.value==0x1FEF807){ // For Load3 On 
load3 = 1; 
 
}
else if(results.value==0x1FEF807){ // For Load3 Off 
load3 = 0; 
  
}

else if(results.value==0x1FE30CF){ // For Load4 On 
load4 = 1; 
 
}
else if(results.value==0x1FE30CF){ // For Load4 Off 
load4 = 0;  
}

else if(results.value==0x1FE48B7){ // For Power On 
power = 1; 
     
}    
else if(results.value==0x1FE48B7){ // For Power Off
power = 0;  
}
    
 irrecv.resume(); // Receive the next value
 delay(100);
 }
}

please anyone can help in this project

You have no debug prints in your code.

Fix that first.

@jamsyogendra - your duplicate topic has been deleted and this one was posted in teh wrong place

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.