Problem with RF Links ! help !

hello guys,
i am working with these RF links : http://www.ekt2.com/products/productdetails?ProductId=3f806822-c96b-43c6-8b93-153c980a4e2d

i made my circuit on the TX side i have a push button, a LED (used for indicator), RF TX
on the RX side i have a LED, and RF RX

now i am trying to make a sketch in which i want to push the button and make the LED on the RX turn on and if i push again it will turn off
so the sketch has some problem it seems nothing is happening when i click the button, i tested the circuit with a multimeter, everything seems fines, the TX and RX data pins are giving a voltage
by the way is it necessary to attach the data pins to PWM ? i was checking some tutorials and none said that, but i remember here on the forum someone told me i must connect it to PWM pin

(Picture Fritzing in the attachment files)
here are the sketches:
TX

//Transmitter

#include <VirtualWire.h>

//Debouncing

int switchPin = 6;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean ledOn = false;


int ArrayController[1];
char valButton = 0;

void setup(){
  pinMode(switchPin, INPUT_PULLUP);
  
  vw_setup(2000);                 // Bits per sec
  vw_set_tx_pin(3); 
  
}

boolean debounce(boolean last)
{
  boolean current = digitalRead(switchPin);
  if(last != current)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;
}

void loop(){
  currentButton = debounce(lastButton);
  if(lastButton == HIGH && currentButton == LOW)
  {
    ledOn = !ledOn;
  
  }
  if(ledOn){
    valButton = 1;
    digitalWrite(4,HIGH);
  }else if(!ledOn){
    valButton = 0;
    digitalWrite(4,LOW);
  }
    
   lastButton = currentButton;
    
   ArrayController[0] = valButton;
   
   vw_send((uint8_t*) & ArrayController, sizeof(ArrayController));
   vw_wait_tx();
}

RX

#include <VirtualWire.h>

int LEDPin = 7;

int receivingArray[1];
int valReceived = 0;

void setup(){
  pinMode(LEDPin, OUTPUT);
  
  vw_setup(2000);                 // Bits per sec
  vw_set_rx_pin(3); 
  vw_rx_start();
  
}

void loop()
{
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  uint8_t buf[buflen];
  
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    memcpy (& receivingArray, buf, buflen);
    valReceived = receivingArray[0];
  
    if(valReceived == 1){
      
      digitalWrite(LEDPin, HIGH);
      
    }else if(valReceived == 0){
      
      digitalWrite(LEDPin, LOW);
      
    }
  }
  
}

How far apart are the transmitter and the receiver.
Whilst it may sound counterinuitive, if they are too close , the receivers AGC gets overloaded by the Transmitter and it wont receive.
Try spacing the receiver a few meters away from the transmitter.

mauried:
How far apart are the transmitter and the receiver.
Whilst it may sound counterinuitive, if they are too close , the receivers AGC gets overloaded by the Transmitter and it wont receive.
Try spacing the receiver a few meters away from the transmitter.

aha ok, i will try, but i forgot to mention that i have a controller, on the controller i have a transmitter of 433mhz and a receiver for 315mhz
and on the car i have the receiver of 433mhz and the transmitter of 315mhz, on the controller the receiver and transmitter are close, and on the car they will be, so you think that might be a problem ?
for this post i removed all from the arduino except of what i showed in the attachment file

i tried to distance the modules but should not be the problem because i used to test them very close before and it words totally fine but not now

Does your debounce circuit work? - it looks like you are switching VCC - is that intentional?
Usually the debounce circuit switches GND, especially since u are using an internal pull-up.

To switch/debounce VCC I would expect an external pull-down resistor.

aisc:
Does your debounce circuit work? - it looks like you are switching VCC - is that intentional?
Usually the debounce circuit switches GND, especially since u are using an internal pull-up.

To switch/debounce VCC I would expect an external pull-down resistor.

the problem was hardware their is a switch between the data and VCC :frowning: i corrected it
and yes you're right the circuit in the picture has that problem for the push button i made the mistake without notice but the actual main one is right

thanks for the help :slight_smile: