User Manual

Sample code
VirtualWire 7 of 13
void loop()
{
const char *msg = "hello";
vw_send((uint8_t *)msg, strlen(msg));
delay(400);
}
5.2 receiver
A simplex (one-way) receiver. Waits for a message and dumps it contents. Test this with
transmitter above.
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);
Serial.println("setup");
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump HEX
Serial.print("Got: ")
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], HEX);
Serial.print(" ");
}
Serial.println("");
}
}
5.3 client
Implements a simple wireless client for DR3100. Sends a message to another Arduino
running the server code below and waits for a reply.
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);// Debugging only
Serial.println("setup");
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{