VirtualWire library

I downloaded VirtualWire library from this page: RF 315/433 MHz Transmitter-receiver Module and Arduino : 5 Steps - Instructables

It won't compile even the .pde file examples, all the functions "not declared in this scope" and the types "does not declare a type". Even though the library is listed in the Library drop down menu, it acts like it is not there. The .h and .cpp files look ok.

Wondering if it is not compatible with Arduino 1.0.5 or something. Does anyone have a suggestion?

Did you remember to change WProgram.h to Arduino.h?

No, I missed that, thanks. Just now changed it to "Arduino.h" but still same problem.
Any more suggestions?

Did you save it after you changed it? Post all the errors you're getting and your code. Please use code tags, its the # above the smiley faces.

Yes, I did save it and closed the IDE then re-opened the sketch. Here is the code from examples:

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

#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
    Serial.begin(9600);	// Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;

        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
	    Serial.print(buf[i], HEX);
	    Serial.print(" ");
	}
	Serial.println("");
        digitalWrite(13, false);
    }
}

Is there a way to copy/paste from the errors? It doesn’t copy, it is very long and typing it would take a very long time.

Thanks for the reply

You can expand the error box and take a screenshot.

Here are some of the errors, leaving out the very long path names:
VirtualWire.h:54: error: variable or field 'vw_set_tx_pin' declared void
VirtualWire.h:54: error: 'uint8_t' was not declared in this scope
VirtualWire.h:58: error: variable or field 'vw_set_rx_pin' declared void
You get the idea. All the functions and types in VirtualWire cause errors

Here is the screenshot.

More info: Tools | Board is set to Uno, it's Win 7, 64 bits. I have used a lot of libraries and have not had this problem unless I had Board set to a chip that didn't support something in the library.

Here is Transmitter sketch copied and pasted from the same website. It is simpler but has the same problem:

//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.h>
char *controller;
void setup() {
  pinMode(13,OUTPUT);
vw_set_ptt_inverted(true); //
vw_set_tx_pin(12);
vw_setup(4000);// speed of data transfer Kbps
}

void loop(){
controller="1"  ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,1);
delay(2000);
controller="0"  ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,0);
delay(2000);

}

The compiler does not know where the library is located. Where did you put it? It should be in the Arduino Sketch folder, in a libraries folder, in your MyDocuments.

I used the Sketch | Import library... of the IDE to install it. It placed it with the rest of my libraries under Contributed. It's there, alright in ... My Documents | Arduino | Libraries, with the rest of the libraries I have added.

It knows where it's at, shows it under Libraries. Something else is wrong, but I cannot figure out what it is.

Well I dont know what else to tell you, your code compiles just fine on my end.

Thanks, anyway. I even traced down the chain of #includes. VirtualWire has a include for CRC16.h which I found exists where it should at Hardware\tools\avr\avr\include\util\crc16.h

Something is wrong or missing but it's a mystery...

By any chance do you have the virtualwire folder inside another virtual wire folder? Meaning if you go to your libraries folder and click on the virtualwire folder, do you see another folder that say virtualwire with the actual examples, .h and .cpp files inside?

The reason I ask is because your errors are without a doubt from the compiler not able to find the library location and if the library is double foldered, this will cause those errors to occur too. However if you have done everything correctly, then it might just be a bug with the software in which you will need to reinstall it. You wont loose any of your sketches.

Found the problem. VirtualWire.h had a #include <Wiring.h>. I had to change that to <Arduino.h>.and now it compiles… Finally! I did a complete computer search and I don’t have wiring.h. It would be really nice if folks would point out which versions of the IDE work with these Instructables downloads.

I had an old release, I guess.

So, from my side is working with Arduino 1.05 without anyproblems ...

Is happen to me into the past also ...

I've format my computer and then download arduino again and then copy libraries inside libraries and the run everything and it's working ok ...

to be honest i don't understand why because no code was changed ...

I hope that can help you regards gnux

hi
i am downloaded virtualwire library and added to libraries but i cant execute programs in "examples" . while am compiling client program in "examples" i am getting these error message.

Arduino: 1.5.5 (Windows 7), Board: "Arduino Uno"

In file included from client.pde:13:
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:54: error: variable or field 'vw_set_tx_pin' declared void
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:54: error: 'uint8_t' was not declared in this scope
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:58: error: variable or field 'vw_set_rx_pin' declared void
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:58: error: 'uint8_t' was not declared in this scope
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:62: error: variable or field 'vw_set_ptt_pin' declared void
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:62: error: 'uint8_t' was not declared in this scope
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:66: error: variable or field 'vw_set_ptt_inverted' declared void
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:66: error: 'uint8_t' was not declared in this scope
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:71: error: variable or field 'vw_setup' declared void
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:71: error: 'uint16_t' was not declared in this scope
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:90: error: 'uint8_t' does not name a type
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:96: error: 'uint8_t' does not name a type
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:99: error: 'uint8_t' does not name a type
C:\Users\user\Documents\Arduino\libraries\VirtualWire/VirtualWire.h:104: error: 'uint8_t' does not name a type
client.pde: In function 'void setup()':
client:25: error: 'vw_set_ptt_inverted' was not declared in this scope
client:26: error: 'vw_setup' was not declared in this scope
client.pde: In function 'void loop()':
client:37: error: 'vw_send' was not declared in this scope
client:43: error: 'vw_wait_rx_max' was not declared in this scope
client:45: error: 'vw_get_message' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

i am downloaded virtualwire library and added to libraries but i cant execute programs in "examples"

Have you actually read this thread, or are you just piling on?

The VirtualWire library at the link in the initial post has not been updated for post 1.0 use. The solution is detailed in this thread, if you'd bothered reading.