VirtualWire – Arduino with RF Module

Transmitter Code:

 

#include <VirtualWire.h>
 
int tx_pin = 12;
 
void setup()
{
  vw_set_tx_pin(tx_pin); 
  vw_setup(2000); 
}
 
void loop()
{
  char msg[] = "About Robotics";
  vw_send((uint8_t *)msg, strlen(msg));
  delay(500);
 
}

Receiver Code:

 

#include <VirtualWire.h>
 
int rx_pin = 3;
 
void setup()
{
  Serial.begin(9600);
  Serial.println("setup");
  vw_set_rx_pin(rx_pin); 
  vw_setup(2000); 
  vw_rx_start(); 
}
 
void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if(vw_get_message(buf, &buflen)) 
  {
    String str = buf;
    Serial.println(str);
  }
}

Proteus Circuit Diagram and Simulation Result:

 

VirtualWire Arduino Library: VirtualWire Arduino library download (electronoobs.com)

Proteus RF Module Library:  Click Here to download

Leave a Reply

Your email address will not be published. Required fields are marked *