Https://community.blynk.cc/t/blynk-with-ir-remote/26140

hello everyone,
i want to add manual control in this project, can anyone help me.

I think you need to start from the beginning:

Get some books about programming; Read, learn, try, fail, experiment with your own code and hardware. Get some results, good, bad, doesn’t matter as long as you learn from them. Debug, adapt, try again!

No-one is going to write the code for you (unless they get some incentive to do so).

If you have a specific problem with your code, you can always ask for guidance. Otherwise, start reading! :slight_smile:

3 Likes

to be very honest i just copy paste work with a little bit of change according to my need previous function and features are working properly
but still not control by manually please,

    > #include <ESP8266WiFi.h>
> #include <BlynkSimpleEsp8266.h>
> 
> // You should get Auth Token in the Blynk App.
> // Go to the Project Settings (nut icon).
> char auth[] = "JKDr-4k6v42pWnSjRlidq88GfVLM7tLG";
> 
> // Your WiFi credentials.
> // Set password to "" for open networks.
> char ssid[] = "Yogendra";
> char pass[] = "Jamsariya";
> //char server[] = "xxx.xxx.xxx.xxx";  // IP for your Local Server
> char server[] = "blynk-cloud.com";
> int port = 8080;
> 
> #ifndef UNIT_TEST
> #include <Arduino.h>
> #endif
> #include <IRremoteESP8266.h>
> #include <IRrecv.h>
> #include <IRutils.h>
> 
> int out1=16; //pin for relay 1 (D0 on nodemcu)
> int before1; //state of relay 1
> int out2=5;  //pin for relay 2 (D1 on nodemcu)
> int before2; //state of relay 2
> 
> int tout1=1; //pin for relay 1 (D0 on nodemcu)
> int touch1; //state of relay 1
> int tout2=13;  //pin for relay 2 (D1 on nodemcu)
> int touch2; //state of relay 2
> 
> int beforeall; // state of the master switch
> 
> uint16_t RECV_PIN = 14; //Pin for the IR Receiver data pin (14=D5 for Node mcu)
> IRrecv irrecv(RECV_PIN);
> 
> decode_results results;
> 
> void setup(){
>    Serial.begin(9600);
>    
>   irrecv.enableIRIn(); // start the receiver
>   before1=1; //Relay1 is turned off
>   pinMode(out1,OUTPUT);
>   before2=1; //Relay2 is turned off
>   pinMode(out2,OUTPUT);
> 
> 
>   pinMode(tout1,INPUT);
>   touch1=1;
>   pinMode(tout2,INPUT);
>   touch2=1;
>   beforeall=1; //Master Switch is off at startup
> 
>   digitalWrite(out1, HIGH); //Making the pins high to keep the relay board off (for active low relays)
>   digitalWrite(out2, HIGH); // make it LOW for active high relay boards.
>   digitalWrite(tout1, LOW); //Making the pins high to keep the relay board off (for active low relays)
>   digitalWrite(tout2, LOW);
> 
>  Blynk.begin(auth, ssid, pass, server, port);    
> }
> 
> BLYNK_WRITE(V10) //Button Widget is writing to pin V10 that is used for master button in app
> {
>   int pinData = param.asInt(); 
>   if (pinData==0){    //Code to turn everything ON/OFF : MASTER SWITCH
>       digitalWrite(out1,LOW); //turning on the relay1 with master button
>       before1=0;
>       Blynk.virtualWrite(V1, 0); //telling the app to display the relay1 button on
>       
>       digitalWrite(out2,LOW); //turning on the relay2 with master button
>       before2=0;
>       Blynk.virtualWrite(V2, 0); //telling the app to display the relay2 button on
>       
>       beforeall=0; //switched the state of master button status to on
>      }
>     if (pinData==1){ 
>       digitalWrite(out1,HIGH);    //this is the opposite of the process 
>       before1=1;
>       Blynk.virtualWrite(V1, 1); //to turn off the relays and the button states changed to off
>       
>       digitalWrite(out2,HIGH);
>       before2=1;
>       Blynk.virtualWrite(V2, 1);
>       
>       beforeall=1; //master button status changed to off
>      }}
> 
> BLYNK_WRITE(V1)    // Virtual pin 1 to contlor relay 1  
> {
>   int pinData = param.asInt(); 
>   if (pinData==0){ 
>       digitalWrite(out1,LOW); //relay1 is now turned on
>       before1=0; 
>      }
>      else if (pinData==0){ 
>       digitalWrite(tout1,LOW); //relay1 is now turned on
>       touch1=0; 
>      }
>     if (pinData==1){ 
>       digitalWrite(out1,HIGH); //relay1 is now turned off
>       before1=1; 
>       }
>        else if (pinData==1){
>       digitalWrite(tout1,LOW); //relay1 is now turned on
>       touch1=1; 
>         }
>        }
> 
> 
> BLYNK_WRITE(V2)    // Virtual pin 1 to contlor relay 1  
> {
>   int pinData = param.asInt(); 
>   if (pinData==0){ 
>       digitalWrite(out2,LOW); //relay1 is now turned on
>       before1=0; 
>      }
>      else if (pinData==0){ 
>       digitalWrite(tout2,LOW); //relay1 is now turned on
>       touch2=0; 
>      }
>     if (pinData==1){ 
>       digitalWrite(out2,HIGH); //relay1 is now turned off
>       before1=1; 
>       }
>        else if (pinData==1){
>       digitalWrite(tout2,LOW); //relay1 is now turned on
>       touch2=1; 
>         }
>        }
> 
> 
> 
> 
>       
> void loop() {
>   if (irrecv.decode(&results)) {    
> 
> //here comes the remote part. the IR decode the hex value and compare
> 
>   if (results.value==0x1FE50AF){ //replace the hex code with yours keeping the prefix 0x
>     if(before1==1){ // if relay1 state was turned off, then we turn it on 
>       digitalWrite(out1,LOW);
>       before1=0; //relay1 is now turned on
>       Blynk.virtualWrite(V1, 0); //sync the data from hardware to app
>     }
>     else{
>       digitalWrite(out1,HIGH); 
>       before1=1; 
>       Blynk.virtualWrite(V1, 1);
>     }}
> 
> 
>   if (results.value==0x1FED827){ 
>     if(before2==1){ 
>       digitalWrite(out2,LOW);
>       before2=0; 
>       Blynk.virtualWrite(V2, 0);
>     }
>     else{
>       digitalWrite(out2,HIGH); 
>       before2=1;
>       Blynk.virtualWrite(V2, 1);
>     }}
> 
> //the master switch for remote
>  
>   if (results.value==0x1FE48B7){ // hex Code to turn everything ON/OFF
>     if(beforeall==1){ // if everything were turned off, then we turn them on 
>       digitalWrite(out1,LOW);
>       before1=0;
>       Blynk.virtualWrite(V1, 0);
>       
>       digitalWrite(out2,LOW);
>       before2=0;
>       Blynk.virtualWrite(V2, 0);
> 
>       beforeall=0;
>       Blynk.virtualWrite(V10, 0); //sync the master button to the app
>     }
>     else{  
>       digitalWrite(out1,HIGH); // if everything were turned off, then we turn them on 
>       before1=1;
>       Blynk.virtualWrite(V1, 1);
>       digitalWrite(out2,HIGH);
>       before2=1;
>       Blynk.virtualWrite(V2, 1);
> 
>       beforeall=1;
>       Blynk.virtualWrite(V10, 1);
>     }}
> 
> 
> irrecv.resume();
>   }
>  Blynk.run();
> }