libraries / VirtualWire / examples / transmitter / transmitter.pdeon commit Added link to project report (97a3ba0)
   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
  13const int led_pin = 11;
  14const int transmit_pin = 12;
  15const int receive_pin = 2;
  16const int transmit_en_pin = 3;
  17
  18void setup()
  19{
  20    // Initialise the IO and ISR
  21    vw_set_tx_pin(transmit_pin);
  22    vw_set_rx_pin(receive_pin);
  23    vw_set_ptt_pin(transmit_en_pin);
  24    vw_set_ptt_inverted(true); // Required for DR3100
  25    vw_setup(2000);       // Bits per sec
  26    pinMode(led_pin, OUTPUT);
  27}
  28
  29byte count = 1;
  30
  31void loop()
  32{
  33  char msg[7] = {'h','e','l','l','o',' ','#'};
  34
  35  msg[6] = count;
  36  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  37  vw_send((uint8_t *)msg, 7);
  38  vw_wait_tx(); // Wait until the whole message is gone
  39  digitalWrite(led_pin, LOW);
  40  delay(1000);
  41  count = count + 1;
  42}