I tried module rf 315 to send and receive data but it's not working so how can I use module rf receiver 315mh T4 to receive data from module rf transmitter 315 data? thank you so much!
This is my code
Transmitter:
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);
Serial.println("Ready.........");
vw_set_ptt_inverted(true);
vw_setup(1024);
vw_set_tx_pin(10);
Serial.write("skdf");
}
void loop()
{
char text[20] = "";// khai báo string d?ng array
byte i = 0;
while (Serial.available() == 0)
{
// nothing
}
while (Serial.available() > 0)
{
char ch = Serial.read();
text[i] = ch;
i++;
delay(5);
}
Serial.print("sent: ");
Serial.println(text);
vw_send((byte *)text, sizeof(text));
vw_wait_tx();
delay(100);
}
And receiver:
#include <VirtualWire.h>
byte msg[VW_MAX_MESSAGE_LEN];
byte msgLen = VW_MAX_MESSAGE_LEN;
void setup()
{
Serial.begin(9600);
Serial.println("READY..........");
vw_setup(1024);
vw_set_rx_pin(5);
vw_rx_start();
}
void loop()
{
if (vw_get_message(msg, &msgLen))
{
Serial.print("got: ");
for (int i = 0; i < msgLen; i++)
{
Serial.write(msg[i]);
}
Serial.println();
}
}
instead of to receive data ?