VirtualWire

so can I just write vw_send(2, 1) ?

No. For 2 reasons. First '2' is not equal to 2. Second, 2 is an int, not an array, and vw_send only sends arrays.

what do you mean 2 is not equal to 2 ? LOL

So everytime I write vw_send(I must include 'uint8_t', length) ?

Thanks

what do you mean 2 is not equal to 2 ? LOL

The number 2 and the letter '2' are not equal.

You mean '2' and 'two' ?

You mean '2' and 'two' ?

No, I mean 2 as in 1+1 and the letter '2', between the letter '1' and the letter '3'.

The letter '2' has an ASCII code of 50. So, if you send '2', the value 50 gets sent. If you send 2, the value 2 gets sent.

Ok, I get you. It all about the usage of the ' ' .

So, everytime I sent a message using vw_send, I have to type it like this : vw_send((uint8_t*)msg, length ) ?

So, everytime I sent a message using vw_send, I have to type it like this : vw_send((uint8_t*)msg, length ) ?

Yes.

And I have to define what is msg ?

For example msg = '2' ?

PaulS:

So, everytime I sent a message using vw_send, I have to type it like this : vw_send((uint8_t*)msg, length ) ?

Yes.

Any alternatif ? And why got a * ?

Because you're casting a pointer.

Okay, I think I have to read more about pointer and array. Thanks !

vw_send(message, length)
Transmit a message. "message" is an array of the bytes to send, and "length" is the number of bytes stored in the array. This function returns immediately and the message is sent slowly by an interrupt-based background process.

so the message is refering to ((uint8_t*)msg), where msg is any number of words ? It is not array anymore because we include the uint8_t already ?

Thanks

For example msg = '2' ?

No.
2 != '2' != "2"

It is not array anymore because we include the uint8_t already ?

I don't understand what you're saying, but obviously it still is an array, because if it were not, then we wouldn't need to specify a buffer length to transmit.

I mean I can also write like this vw_send(char msg[8],8) ? Instead of writing it like vw_send((uint8_t*)msg,8), char msg[8] = {'1','2','3','4','5','6','7','8'}

Hahaha.. well, so confuse ><

Yes, you can write it like that, but you need to declare the array before the call.

So the purpose of adding (uint8_t*)msg is just to tell that the message is an array of 8 bits.

Am I correct ?

The function expects to be given an array of type uint8_t.
If you give it an array of that type, you don't need the cast.

Okay. Got it.

Means if I give the function unsigned integer with 8 bits(An array), then I do not need to write the keyword uint8_t ?

Correct ?
Heheh

Means if I give the function unsigned integer with 8 bits(An array), then I do not need to write the keyword uint8_t ?

Correct ?

No. An unsigned integer is not an array and it isn't 8 bits.

So, if I want to send a number 2, then how do I wrote it in array of 8 bits ??? Thanks

So, if I want to send a number 2, then how do I wrote it in array of 8 bits ??? Thanks

uint8_t msg[1] = 2;
vw_send(msg, 1);