Go Down

Topic: VirtualWire program not compiling (Read 210 times) previous topic - next topic

Nitnats

I'm relatively new to all this.

So, I have the latest VirtualWire library in the library folder (version 1.10), but every time I try to run the sample transmitter program, I get

'vw_set_tx_pin' was not declared in this scope



Here is the sample code:
Quote

// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

const int led_pin = 11;
const int transmit_pin = 12;
const int receive_pin = 2;
const int transmit_en_pin = 3;

void setup()
{
  // Initialise the IO and ISR
  vw_set_tx_pin(transmit_pin);
  vw_set_rx_pin(receive_pin);
  vw_set_ptt_pin(transmit_en_pin);
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);    // Bits per sec
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};

  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}



I've been scouring the forums and I've tried redownloading the library and replacing the old one, restarting the IDE, etc.

Any ideas on what to do?

PaulS

Quote
Any ideas on what to do?

You could tell us what version of the IDE you are using. You could tell us what error messages you are getting.

I copied the code into the 1.0.1 IDE, and got several errors. I am using an older version of the library, apparently. I needed to change wiring.h to Arduino.h in VirtualWire.h, and remove the include of WProgram.h from VirtualWire.cpp. Then, the code compiled.

Go Up