Problem with 2 way communication rf coding

Hello everyone, I'm new here. I just made a two way communication by using 2 433MHz RF modules with 2 arduino Uno, LEDs and push buttons. Unfortunately, I've tried so many coding for arduino but failed. Please help me... :sob: :sob: :sob:

Please help me.

With what? What data are you trying to send? Using what code?

How are you trying to receive the data? What are you going to do with the data?

I use 2 arduinos with Rx and Tx for each arduino so both arduinos can transmit and receive data between each other. I use push button A as input and led A as output for the first arduino and push button B as input and led B as output, so when I trigger push button A, led B will turn ON and when I trigger push button B, led A will turn ON. I've tried so many coding but failed. :sob:

I've tried so many coding but failed.

Probably because you do not have any real requirements. You failed to answer any of my questions.

You can skip the first one. The answer to that is clearly "everything". You can NOT skip any of the other 4.

If you can not describe what data you want to send, you haven't a hope in hell of writing code to send that data. If you haven't sent anything, how can you write code to receive that data?

My coding for 1 ways communication

Transmitter
#include <VirtualWire.h>

int button_gate = 3;

int button_gate_read = 0;

void setup()
{
Serial.begin(9600);

pinMode(button_gate, INPUT);

vw_setup(2000);
vw_set_tx_pin(7);
}

void loop()
{
char on[1] = {‘2’};
char off[1] = {‘3’};

button_gate_read = digitalRead(button_gate);

if (button_gate_read == HIGH)
{

vw_send((uint8_t *)on, 1);
}
else if (button_gate_read == LOW)
{

vw_send((uint8_t *)off, 1);
}
}

My coding for 1 way communication using rf

Receiver

//Reciever Code (Leonardo)
#include <VirtualWire.h>

void setup()
{
pinMode(13,OUTPUT);
digitalWrite(13,LOW);

vw_setup(2000);
vw_set_rx_pin(7);
vw_rx_start();
}

void loop()
{
uint8_t buflen = VW_MAX_MESSAGE_LEN;
uint8_t buf[buflen];

if(vw_get_message(buf, &buflen))
{
for(int i = 0;i < buflen;i++)
{
if(buf == ‘2’)

  • {*
  • digitalWrite(13,HIGH);*
  • }*
    _ else if(buf == ‘3’)_
    * {*
    * digitalWrite(13,LOW);*
    * }*
    * }*
    * }*
    }

up there is my code that we use for 1 way communication , and now we still not found 2 way communication coding even we edit that 1 way coding