Please help with data types ...

Hello, this is my first (well, second) Arduino Project and I have adapted VirtualWire's example code to transmit an integer value via a RF module. Right now I have this on the transmitter side:

int numbers[1];
numbers[0]=0;    

(...)

void loop()
{

    vw_send((uint8_t *)numbers, sizeof(numbers));
    vw_wait_tx();
    delay(5);
    numbers[0]++;

}

This is working alright, and I'm getting the results I was expecting. However, since I only need to transmit a single integer value, I figured I could as well take the data type "int" instead of an array of integers:

int number = 0;    

(...)

void loop()
{

    vw_send((uint8_t *)number, sizeof(number));
    vw_wait_tx();
    delay(5);
    number++;

}

This does not work any more, i.e. I'm getting funny results. Could anyone please explain why?

This is the receiving end, btw:

void loop()
{
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    i = word(buf[1],buf[0]);
      Serial.println(i,BIN);

  }

Thanks! Phil

vw_send((uint8_t *) [glow]&[/glow]number, sizeof([glow]int[/glow]));

You need to take the address of number, not number itself. That's the &.

Korman

THANKS A TON, it's working like a charm now. I come from a Delphi background and have avoided pointers whenever I could ;-) ... Guess I will have to do some reading on the topic.

Thanks again for the quick reply!