Virtual Wire with multiple receivers

Hello Arduino community, I'm trying to create a one way communication with one transmitter and many recievers using the virtual wire library. (Like one of those pager systems at restaurants that tell you when your table is ready.)
I have three arduino uno's a 4x4 matrix keypad, rbg leds and xd fs1000a 5v 433mhz transmitter and receivers. (In the future I want to have thousands of receivers using cheaper attiny or something similar.) Each receiver is equipped with a rbg led, when it recieves the correct code it should light the corresponding led. I also tried to have a function to save a new id number for the receiver; and a function to turn all of the receivers coresponding leds on or off.
I don't have internet and am writing this on my phone so please forgive me,

//This is my transmitter

#include <VirtualWire.h>
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys [ROWS] [COLS] = { 
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins [ROWS] ={
9, 8, 7, 6};
byte colPins [COLS] ={
5, 4, 3, 2};
Keypad keypad = Keypad (makeKeymap (keys), rowPins, colPins, ROWS, COLS );
byte ledPin = 11;
const int transmit_pin = 12;
#define Message_Length 12
char Data[Message_Length];
byte dataCount = 0;
void setup() {
vw_set_tx_pin (transmit_pin);
Serial.begin (9600);
pinMode (ledPin, OUTPUT);
keypad.addEventListener (keypadEvent);
vw_setup (1200);
}
void loop() {
char key = keypad.getKey();
 if ( key) {
Data [dataCount] = key;
Serial.println (Data [dataCount]);
dataCount++;
 }
}
void keypadEvent (KeypadEvent key){
switch (keypad.getState()) {
case PRESSED:
if (key =='#') {
digitalWrite (ledPin, HIGH);
vw_send ((unit8_t *) Data, 12);
vw_wait_tx();
clearData();
digitalWrite (ledPin, LOW);
delay (1000);
}
if (key == 'C') {
clearData();
}
break;
 }
}
void clearData() {
while (dataCount !=0)
{
Data [dataCount--] = 0;
}
return;
}

This works well except the clearData function. It will leave either a 'C' or a '#' in the buffer after the first transmition or clear function. I worked around this by ignoring the zero index on the receiver end.

This is my receiver

#include <VirtualWire.h>
String panId ="#0000";
int ledRed = 5;
int ledGreen = 10;
int ledBlue = 6;
void setup() {
Serial.begin (9600);
Serial.println ("setup");
vw_set_rx_pin (11);
vw_setup(1200);
vw_rx_start();
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
unit8_t buf[VW_MAX_MESSAGE_LEN];
unit8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) {
int i;
Serial.print("Got");
for (i = 0; i < buflen; i++) {
char c = (buf[i];
Serial.print (c);
Serial.print(" ");
// turns all receivers leds off
if (buf[6] =='6') {
digitalWrite (ledRed, LOW);
digitalWrite (ledGreen, LOW);
digitalWrite (ledBlue, LOW);
}
// turns all receivers green led on
if (buf[6]=='8') {
digitalWrite (ledGreen, HIGH);
}
//nothing from here down seems to work
if (buf[1] ==(panId[1])) {
if (buf[2]== (panId[2])) {
if (buf[3]== (panId[3])) {
if (buf[4]== (panId[4])) {
 if (buf[6]== '1') {
analogWrite (ledGreen, 200);
 }
 if (buf[6]== '2') {
analogWrite (ledBlue, 50);
 }
 if (buf[6]=='3') {
analogWrite (ledRed, 150);
 }
 if (buf[6]=='4') {
digitalWrite (ledRed, LOW);
digitalWrite (ledGreen, LOW);
digitalWrite (ledBlue, LOW);
 }
// trying to save a new panId
 if (buf[6]=='7') {
panId[1] = buf[7];
panId[2] = buf[8];
panId[3] = buf[9];
panId[4] = buf[10];
Serial.print(panId);
 }
        }
       }
      }
     }
    }
  }
}

The receiver code can only turn all green leds on and off. I can see the received code on the serial monitor and everything coming from the transmitter looks good. But the individually addressed functions don't work yet. Am I using to many if statements? Is there an easier way? I'm new to coding and trying to learn every day, so I thank you in advance for your help and patients.
Sincerely Travis Doyle travisdoylecdt@gmail.com

#define Message_Length 12
char Data[Message_Lenght];

Your speelchekcer appears to have failed you.

char key = keypad.getKey();
 if ( key) {
Data [dataCount] = key;
Serial.println (Data [dataCount]);
dataCount++;
 }

You appear to have forgotten that you added a callback to deal with the keypad.

while (dataCount !=0)
{
Data [dataCount--] = 0;
}

Suppose that dataCount contains 10. Which array elements are you modifying?

Do you not understand that simply putting a NULL in position 0 of the array is sufficient?

How do you KNOW that the array is not properly "cleared"?

Post the code you are REALLY running.

Hi PaulS, thanks for catching that lenght length. I'm transcribing from my desktop to my phone so I'd be surprised if there aren't more.

 char key =keypad.getKey();
if ( key) {
Data [dataCount] = key;
Serial.println (Data [dataCount];
DataCount++
}

"You appear to have forgotten that you added a callback to deal with the keypad."
I have to be honest, I have no clue what that means. I've been trying to read up and it's mostly over my head. I used that piece of code above to save the keys entered in to a Data array so I could send more than one char at a time. It seems to work well. When I open two instances of the ide on separate ports and open the serial monitors, I can see the chars entered on the keypad for example (1234). If I hit # on the keypad it will send the Data string (1234) using the virtual wire library. Then it runs the clear data data function.
On the receiver side for the first transmition I will receive (1234), but if I attempt to send (1234) a second time I will receive (#1234). The same thing happens when I enter (C) to clear the Data array. If I attempt to send (1234) after clearing a previous entry, I will receive (C1234). Being new to coding I chose to just ignore this problem until I can better understand what's happening. So I modified my receiver code to start comparing on index 1 instead of index 0. And that seemed to work, I can turn on and off a green light using the virtual wire keypad transmitter, but it turns on the green light for all the receivers. When trying to compare recieved data to panId I fail, nothing happens. I can see the recieved data in the serial monitor but no lights.

"Suppose that the dataCount contains 10. Which array elements are you modifying?"
I was thinking that the last four elements would replace the panId.

In the receiver code buf array[6] is the action variable. For example (#123408)If buf[6] =='8' all the receivers turn on the green led.
Action 7 is supposed to save a new id for the receiver. If I were to send (#1234072222) on the keypad transmitter, the receiver with panId #1234 would save 2222 in position 1-4 of the panId array (#2222) in theory.

Fun project!

while (dataCount !=0)
{
Data [dataCount--] = 0;
}

This doesn't work as you expect because Data[0] is never cleared.

Don't mix character arrays (C strings) and Strings. In fact there is no reason to use Strings.

There are simple functions to compare character arrays or search for substrings in strings, like strcmp(), strstr() etc. Use them instead of writing complex "if" clauses. See C Library -

I have to be honest, I have no clue what that means. I've been trying to read up and it's mostly over my head.

You registered an event handler:

keypad.addEventListener (keypadEvent);

What this means is that ALL actions involving the keypad should be handled by the leypadEvent() function.

The loop() function should NOT be reading the keypad AT ALL.