Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
#include <rcswitch.h>
#include <eeprom.h>

RCSwitch mySwitch = RCSwitch();
int LED1 = 3; // load1 Pin out
int LED2 = 4; //load2 Pin out

int load1, load2;

void setup() {\
  
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2

  load1 = EEPROM.read(1);
  load2 = EEPROM.read(2); 
  
  pinMode(LED1,OUTPUT); digitalWrite(LED1, load1);
  pinMode(LED2,OUTPUT); digitalWrite(LED1, load2);
  delay(100);
  
}

void loop() {
  if (mySwitch.available()>0) 
  {
    
    unsigned long int num = mySwitch.getReceivedValue();
    Serial.print(num);
    switch(num)
    {
      case 255650: mySwitch.disableReceive();
                   load1 = !load1;
                   EEPROM.write(1,load1);
                   break;
      case 255656: mySwitch.disableReceive();
                   load2 = !load2;
                   EEPROM.write(2,load2);
                   break;
       
      
    }
    digitalWrite(LED1, load1);
    digitalWrite(LED2, load2);
    
    unsigned long time_now = millis();
    int ck = 100;
    while(millis() < time_now + ck){;}  
           
     mySwitch.resetAvailable();
     mySwitch.enableReceive(0);
  }
}


What I have tried:

I've tried google for a similar code but couldn't find it .
Posted
Updated 19-Apr-21 21:55pm
v3

It looks you are using an Arduino (or a similar) board. You may find many examples of I2C, just look for the Wire library.
 
Share this answer
 
Comments
Ganesh Kumar Apr2021 20-Apr-21 2:24am    
ive searched bro, i know how to connect the lcd to the arduino but i cant find any solution to bind together with my current rf code.
CPallini 20-Apr-21 2:37am    
Try, using a simple example to make the I2C LCD work. Then you may easily figure out how to join the two projects.
Try Tinkercad | From mind to design in minutes[^] they have many samples.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900