1// transmitter.pde
2//
3// Simple example of how to use VirtualWire to transmit messages
4// Implements a simplex (one-way) transmitter with an TX-C1 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: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
10
11#include <VirtualWire.h>
12#undef int
13#undef abs
14#undef double
15#undef float
16#undef round
17#include "WProgram.h"
18void setup();
19void loop();
20void setup()
21{
22 Serial.begin(9600); // Debugging only
23 Serial.println("setup");
24
25 // Initialise the IO and ISR
26 vw_set_ptt_inverted(true); // Required for DR3100
27 vw_setup(2000); // Bits per sec
28}
29
30void loop()
31{
32 const char *msg = "hello";
33
34 digitalWrite(13, true); // Flash a light to show transmitting
35 vw_send((uint8_t *)msg, strlen(msg));
36 vw_wait_tx(); // Wait until the whole message is gone
37 digitalWrite(13, false);
38 delay(200);
39}
40
41int main(void)
42{
43 init();
44
45 setup();
46
47 for (;;)
48 loop();
49
50 return 0;
51}
52