VirtualWire receiver breaks other code

I had an initial memory issue which was resolved in this thread: http://arduino.cc/forum/index.php/topic,158714.0.html

I have a system setup to control a 25x15 LED array which is working just fine. Now, I am trying to add in some code into the program to receive data from a WRL-10532 radio receiver to control what is displayed on the LED array using the VirtualWire library.

My code is attached (too large to post in topic). The thing is that if I comment out the init code for the receiver, the LED array works fine. If though, I keep the init code for the receiver active, the LED board is always ON. All LEDs are on.

It is strange though since if I output everything with Serial, all data is just fine. Just commenting out the init code (nothing else) fixes the issue and the LEDs do what they are supposed to. I can keep all other VirtualWire receiver code in, no problem.

The problem code is on line 269 - 272. Disconnecting all wires for the radio receiver doesn’t make any change. What could be causing this very strange problem?

Backpack.ino (31.9 KB)

I would be a little concerned about the amount of free memory, especially since your receive buffer is on the stack. Search the forum for "free memory function" and you'll find some code that will tell you how much RAM is free. If it's less than 200 you might be seeing a stack overflow.

I also wonder whether setting the rx_pin before calling vw_setup might help:

  // instead of this:
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);// Bits per sec
  vw_set_rx_pin(receivePin);
  vw_rx_start();// Start the receiver PLL running
  // is this any better:
  vw_set_rx_pin(receivePin);
  vw_setup(2000);// Bits per sec
  vw_rx_start();// Start the receiver PLL running

Edit: Also, unless you have a devious plan that requires using int values instead of char or byte, you could save 100 bytes of RAM right away by switching to char if the values in this array will never exceed 255:

int scrollingLetterKeys[maxScrollingLetterKeys];

-br

All suggestions were taken in and everything works perfectly now! Thanks!