Need syntax help for VirtualWire

Hi,
I've got an Arduino sending and a 2nd receiving using Mike McAuley's Virtualwire demo programs and the sparkfun 434 MHz Tx/Rx modules (the 4800 units). Unfortunately, I'm really a hardware guy and haven't programmed much in ages, so I'm struggling with some of the more complex coding.

I can't figure out how to mod these 2 lines in the TX program to send out the value out the value of "key" from the matriz keypad program:

const char *msg = "hello";
vw_send((uint8_t *)msg, strlen(msg));

"key" will be from 0-F, with just 1 button push at a time sending out 1 character.

Doing some lunchtime forum browsing at work, I see that

char *msg

defines a pointer to a char character.

So if I change to this, will that do it for me?
:
:
// all the other stuff from the keypad tutorial and setup stuff for the
// wireless goes here
:
:
void loop()
{
char key = keypad.getKey();

if(key) // same as if(key != NO_KEY)
{
char msg;
msg
= &message;

// send the keypress out over wireless

char message = key
vw_send((uint8_t *)&message
(plus the wait for end of transmit line that goes here)

} // end of if(key)
} // go back to waitng for next keypress

I realize this keeps the Arduino spinning its wheels waiting for that rare keypress, I plan to improve after this to do the wake on keypress described by Atmel here:

Thanks,
Robert

The const char *msg declaration could be changed to const char msg[n], where n represents some size. Then, msg[0] could be initialized with the value of the key pressed. msg[1] should be set to NULL. Then, send the msg array, with a length of 1.

Thank you PaulS. I'll have to do some reading on getting the key data into an array, that's something new for me.
This will be the transmitter for a remote control, so its just the 1 byte (wrapped in the Virtualwire encoding), maybe 3-4 presses in 3-4 seconds max (say 1 to reset the score, 1 to reset the time, 1 more to do something else, like update the score, or a turn on a penalty light). Then a long delay until the next one couple of presses.

Robert

Got it working! Wasn't too bad, mashing some of the examples together and tweaking a little for the 4x4 keypad I have. Thanks for the info about the arrays PaulS.

Is there a way to post pictures of my collection of bits & pieces?

// transmitter_mine.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

// uses default pin 12 for transmit data

// merged in the matrix keypad example & tweaked things to put out 
// the 'key' captured

#include <VirtualWire.h>
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
// Define the Keymap
char keys[ROWS][COLS] = 
{
  {  '1','4','7','*'  },
  {  '2','5','8','0'  },
  {  '3','6','9','#'  },
  {  'A','B','C','D'  }
};

// Connect keypad ROW1, ROW2, ROW3 and ROW4 to these Arduino pins.
byte rowPins[ROWS] = { 3,4,5,6 };
// Connect keypad COL1, COL2, COL3, COL4 to these Arduino pins.
byte colPins[COLS] = { 7,8,9,10 }; 

// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

#define ledPin 13
char msg[2];

void setup()
{
  digitalWrite(ledPin, LOW);
  Serial.begin(9600);        // Debugging only
  Serial.println("TX setup");

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

void loop()
{
  char key = keypad.getKey();
  if(key)  // same as if(key != NO_KEY)
  {
    msg[0]=key;

    digitalWrite(ledPin, true); // Flash a light to show transmitting
    Serial.println("sending:  ");
    Serial.println(key);

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

    digitalWrite(ledPin, false);

    delay(100);
  }
}

and the recieve side is just Mike's straight up receiver program.

Now to build up the receive hardware to turn on lights and change score counters depending on the buttons pushed.

Robert