formatting data for VirtualWire ?

I have ( with a load of help from Crossroads and his fencing timer ) got my wireless shotclock timer transmitter working.

But my data is different to what he has, and I am stuck on how to package the data and send it.

I have a timer, counting down from 60 seconds max, and a "pause" signal, which is sent to 2 remote displays, each with a 2 digit LED display.

The timer side is working fine , the time left "T" is an integer, and the pause, and on/off signals are either 1 or 0.

I also have a 4 bit address set from dip switches from binary switches

  add3 = digitalRead(SW3); 
  // shift it left 3 places
  add3 = add3 << 3;
  add2 = digitalRead(SW2);
  // shift it left 2 places
  add2 = add2 << 2;
  add1 = digitalRead(SW1);
  // shift it left 1 place
  add1 = add1 << 1;
  add0 = digitalRead(SW0);
  // now OR it together
  address = address|add3;
  address = address|add2;
  address = address|add1;
  address = address|add0;
 Serial.println("my address is: ");
Serial.println(address, BIN);
  msg[1]= address;

When the "preset seconds " on the remote is pressed, (or when the pause button is pressed ) I want to send the time in seconds "T", and send "pause" as high .

The slave units must then update their countdown to the master one, and pause.

When the "run" button is pressed I want to send the master time in seconds "T", and send "pause" as low .

The slaves will again be reset to the master and carry on the countdown.

I am not sure how the msg[0] and msg [1] are working,

Can anyone guide me how to send my 6 bits of time "T", my "pause" bit, my 4 bit binary address . and another bit for "on"

I am struggling to see how to make them into a message, that I can separate at the receiver end, which is my next task, at the moment I am just looking at the data from the receiver, I need to know how to set up the VW message receiving .

I am not sure how the msg[0] and msg [1] are working,

Can anyone guide me how to send my 6 bits of time "T", my "pause" bit, my 4 bit binary address . and another bit for "on"

From the code you posted, it is impossible to answer the question. We don't know how msg is defined, sent, or received.

The simplest solution is to change msg to an array of 4 values. Put time in msg[], the pause flag in msg[1], the address in msg[2], and the on bit in msg[4].

The on and pause bits could be "or"ed the same way that the switch states are, in address, so you can stay at two bytes.

Thanks Paul I will try that

OK I found I don't need the on/off, or the pause command as such, I can just transmit the key number, the address number , and the time.

I have got

msg[0]=key;
msg [1] = address;
msg[2]=T;

vw_send((uint8_t *)msg, strlen(msg)); // send the character out
vw_wait_tx(); // Wait until the whole message is gone

What do I tell the receiver to look for, and how do I separate the data? The example shows

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{

I have got it sorted thanks Tx side after defining char msg [3];

    msg[0]= address; 
    msg[1]= key;
    msg[2] = T;   // seconds remining in countdown

    digitalWrite(ledPin, true);               // turn on Tx supply and LED to show transmitting


    vw_send((uint8_t *)msg, strlen(msg));     // send the character out  

    vw_wait_tx();                             // Wait until the whole message is gone
    delay (50); 

     digitalWrite(ledPin, false);              // turn off theTx and  LED

and the Rx side :-

{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking
{
  
 Serial.println("Got: ");  // Show on PC for debugging

   Serial.print(" unit ID = ");
    Serial.println(buf[0], DEC);
    
    Serial.print(" key number = "); 
     Serial.println(buf[1], DEC);
     
      Serial.print(" seconds remaining = ");
      Serial.println(buf[2], DEC);