315 MHz Tx and Rx problems.

I have had the pair for almost a week now and I have had no luck being able to connect them to work. I have various tutorials along with the datasheets that I used and I could not connect them because that is usually how I learn about the sensors I am using in my project. I got some new code that I thought would be nice for me to use considering the fact I just want to send simple messages back and forth using one pair of 315 mhz and one 433 mhz. Ok so the code I am currently using uploads fine and all but I haven't been able to receive anything on the serial monitor?
Is something wrong with the code or did I wire it incorrectly which I don't think is possible because I wired it the same way the datasheet from sparkfun had for both of them.
transmitter(mega)

// Arduino mega tx

#include <VirtualWire.h>  
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{

  vw_set_ptt_inverted(true); 
  vw_setup(2000);                 // Bits per sec
  vw_set_tx_pin(3);                // pin 3 is used as the transmit data out into the TX Link module, change this to suit your needs. 
}

void loop()
{
  const char *msg = "String Sent";       // this is your message to send

  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();                                          // Wait for message to finish
  delay(200);
}

receiver code (uno)

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


  vw_set_ptt_inverted(true);    
  vw_setup(2000);                   
  vw_set_rx_pin(12);            
  vw_rx_start();                      // Start the receiver 
}

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

  if (vw_get_message(buf, &buflen)) // check to see if anything has been received
  {
    int i;
    // Message with a good checksum received.

    for (i = 0; i < buflen; i++)
    {
      Serial.print(buf[i]); 
    }
    Serial.println("");
  }
}

Thanks so much for the help!

What are the voltages to the transmitter and receiver? And what is the baud rate set to on your Serial monitor?

5v(to both) and 9600 baud rate.

Try these.

Transmitter:

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);	  // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_setup(2000);	 // Bits per sec
    vw_set_tx_pin(3); 
}

void loop()
{
  char *msg;
  msg = "Hi";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
}

Receiver:

#include <VirtualWire.h>

void setup()
{
  Serial.begin(9600);	// Debugging only
  Serial.println("setup");
  
  vw_setup(2000);	 // Bits per sec
  vw_set_rx_pin(2);     // receiver pin
  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
  {
    for(int i =0; i < buflen; i++)
    {
      Serial.print(buf[i]);    
    } 
  }
}

Still nothing.
I even attempted to change the antenna by taking it out and then testing but nothing. I then put them back in the breadboards but still nothing.
The antenna's are close to 5 inches and are
normal wires. Also, I tried different distances less than a foot away and more than 3 feet away.
Should I try the 433 MHz pair to see if there is a messed up tx or rx?

You have both the 433 and 315? Maybe your using the wrong "pairs". My guess is one of them is 433 and the other is 315.

I don't think so, I mean I haven't packages of the 434 yet due to the fact I didn't want to mix them up but they might have got mixed up in shipping ?
Do you think I should post pictures(or use a program to post the diagram) of the set up if i can't get them to work after seeing if they got mixed up ? That would be the only thing I can honestly think of being wrong if it's not the wrong pair.
Thanks.

If you can provide pictures, then post them. Post your setup, and wiring too.

Hey, I received a problem when I tested the volts and I posted this in electronics but I think I should have posted it here since I was able to today.
So,
My wiring is set up(from left to right) for my mega connected to the Transmitter by a breadboard with a 5v battery pack as the power source. First wire orange connected to ground, second wire green connected to digital pin 39(I tried various pins and it didn't work), third wire another orange connected to 5v, and fourth wire green used as an antenna extending out.
My wiring for the Receiver which is connected to my Uno through a BOE shield breadboard with a USB as the power source. Wiring from left to right: First wire green I have connected to ground, second wire yellow I connected to digital pin 5, third wire green I connected to ground, fourth wire yellow I connected to 5v, fifth wire yellow I connected to 5v again, sixth wire green I connected to ground, seventh wire yellow I connected to ground as well, eighth wire green was used as an antenna.
https://www.sparkfun.com/datasheets/RF/KLP_Walkthrough.pdf is where I got the way to wire them, and is in the suggested links part for these models.
RF Link Transmitter - 315MHz - WRL-10535 - SparkFun Electronics is the transmitter and RF Link Receiver - 4800bps (315MHz) - WRL-10533 - SparkFun Electronics

Pictures:

is the uno and the BOE shield.

Is the mega and the breadboard.

You might just have a defective device.

As the saying goes, it's no use flogging a dead horse.

Get another one and see if that works.

I have the 315 Mhz(one pair) and the same exact pair but a different frequency. I don't think the device is defective it has to do with one of the boards I believe. I scanned the volts coming out and It was really weird. When I scanned the two different devices with a 5v battery pack they were both 5v but when my uno had a USB connected to it it was 4.22 I just bought a new one because my old USB had different results with the mega having 4.23 and the uno having 3.67 volts.

In the picture with your transmitter, you have the data line on pin 39, but your transmitter's code is set for pin 3. Which one is it really?

It is 39, I tried various data pins(changed the code accordingly)