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@airspayce.com)
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
13void setup()
14{
15 Serial.begin(9600); // Debugging only
16 Serial.println("setup");
17
18 // Initialise the IO and ISR
19 pinMode(12, OUTPUT);
20 vw_set_tx_pin(12);
21 vw_set_ptt_inverted(true); // Required for DR3100
22 vw_setup(2000); // Bits per sec
23}
24
25void loop()
26{
27 const char *msg = "hello";
28
29 digitalWrite(13, true); // Flash a light to show transmitting
30 vw_send((uint8_t *)msg, strlen(msg));
31 vw_wait_tx(); // Wait until the whole message is gone
32 Serial.println("Transmitted!");
33 digitalWrite(13, false);
34 delay(2000);
35}