User Manual

Sample code
6 of 13 VirtualWire
Block and wait until the transmitter is idle
4.9 vw_wait_rx
xtern void vw_wait_rx();
Block and wait until a message is available from the receiver.
4.10 vw_wait_rx_max
extern uint8_t vw_wait_rx_max(unsigned long milliseconds);
Wait at most milliseconds ms for a message to be received. Return true if a message is
available.
4.11 vw_send
extern uint8_t vw_send(uint8_t* buf, uint8_t len);
Send a message with the given length. Returns almost immediately, and the message
will be sent at the right timing by interrupts. Returns true if the message was accepted
for transmission. Returns false if the message is too long (>VW_MAX_PAYLOAD).
4.12 vw_have_message
extern uint8_t vw_have_message();
Returns true if an unread message is available from the receiver.
4.13 vw_get_message
extern uint8_t vw_get_message(uint8_t* buf, uint8_t* len);
If a message is available (good checksum or not), copies up to *len octets to buf.
Returns true if there was a message and the checksum was good.
5.0 Sample code
The following samples are available as examples in the VirtualWire distribution.
5.1 transmitter
A simplex (one-way) transmitter. Sends a short message every 400 ms. Test this with the
receiver below.
#include <VirtualWire.h>
void setup()
{
vw_setup(2000); // Bits per sec
}