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 $
1011
#include <VirtualWire.h>
1213
const int led_pin = 11;
14const int transmit_pin = 12;
15const int receive_pin = 2;
16const int transmit_en_pin = 3;
1718
void setup()
19{
20// Initialise the IO and ISR
21vw_set_tx_pin(transmit_pin);
22vw_set_rx_pin(receive_pin);
23vw_set_ptt_pin(transmit_en_pin);
24vw_set_ptt_inverted(true); // Required for DR3100
25vw_setup(2000); // Bits per sec
26pinMode(led_pin, OUTPUT);
27}
2829
byte count = 1;
3031
void loop()
32{
33char msg[7] = {'h','e','l','l','o',' ','#'};
3435
msg[6] = count;
36digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
37vw_send((uint8_t *)msg, 7);
38vw_wait_tx(); // Wait until the whole message is gone
39digitalWrite(led_pin, LOW);
40delay(1000);
41count = count + 1;
42}