1// receiver.pde
2//
3// Simple example of how to use VirtualWire to receive messages
4// Implements a simplex (one-way) receiver with an Rx-B1 module
5//
6// See VirtualWire.h for detailed API docs
7// Author: Mike McCauley (mikem@open.com.au)
8// Copyright (C) 2008 Mike McCauley
9// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
1011
#include <VirtualWire.h>
12#undef int
13#undef abs
14#undef double
15#undef float
16#undef round
17void setup()
18{
19Serial.begin(9600); // Debugging only
20Serial.println("setup");
2122
// Initialise the IO and ISR
23vw_set_ptt_inverted(true); // Required for DR3100
24vw_setup(2000); // Bits per sec
2526
vw_rx_start(); // Start the receiver PLL running
27}
2829
void loop()
30{
31uint8_t buf[VW_MAX_MESSAGE_LEN];
32uint8_t buflen = VW_MAX_MESSAGE_LEN;
3334
if (vw_get_message(buf, &buflen)) // Non-blocking
35{
36int i;
3738
digitalWrite(13, true); // Flash a light to show received good message
39// Message with a good checksum received, dump it.
40Serial.print("Got: ");
4142
for (i = 0; i < buflen; i++)
43{
44Serial.print(buf[i], HEX);
45Serial.print(" ");
46}
47Serial.println("");
48digitalWrite(13, false);
49}
50}