VirtualWire library - vw_setup is disabling pin input

Hi everyone, Im quite newbie in arduino, I can write some simple codes, but this one I cant figure out, google is not helping. sory about my english :slight_smile:

Im using RF module for sensor, and cant make it work. I was trying to use simple button code, and upgrade it by adding lines for VirtualWire library.

Heres the code (I make it the simplest posibble to find problem):

#include <VirtualWire.h>
char *controller;
int buttonState = 0;

void setup() {

  pinMode(13, OUTPUT);
  pinMode(11, INPUT);

  vw_set_ptt_inverted(true); //
  vw_setup(1000);
  vw_set_tx_pin(12);

}

void loop() {


  if (digitalRead(11) == HIGH) {
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
}

when I add vw_setup(1000) as first line in setup, pin input 11 stop working at all. When I put this line after setup pin mode, LED on pin 13 is always on.

why vw_setup(1000) is affecting pin input/output? and why change position of this line change behavior of the pins? i thought order in setup doesnt matter... thanks for advices!

The best advice to give you is to:

(1) read the VirtualWire documentation
(2) study the simple provided examples and
(3) get at least one of them working before modifying anything.

If you had done that, you would have known that pin 11 is the default VirtualWire receive pin.
YOU should not be doing anything with pin 11, except to attach a receiver to it.

Well, I try some example for VirtualVire and it worked well. Buton code worked as well. So I try to combine them.

I change input pin to 10, put all lines for VirtualWire library before pin mode setup, and its working now. I just guess, that when I change pin for transmiter from 11 to 12, 11 will be just normal pin after that.

Thanks for help. Still doesnt work, pin input reacts when I connect BARE wire to it, like there is some signal/voltage, but its for another thread.

pin input reacts when I connect BARE wire to it, like there is some signal/voltage

Of course it does. That is called a "floating input" and should be avoided.