I am trying to write a pice of code which send to a receiver the frequency to listen.
As per its documentation, it should receive the following sequence:
Example with 123.456 MHz
Command to send (frequency converted in 4 bytes, followed by 2 instruction bytes
0x12 0x23 0x56 0x00 0x01
To be able to memorize six frequencies, I fill an array:
uint32_t mem_freq[6] = {
0x121050,
0x126500,
0x120500,
0x121700,
0x121825,
0x118700,
};
My concern is that when I do :
Serial.write(mem_freq[mem_index]);
//Serial.write(0x00);
//Serial.write(0x01);
Only 1 byte is sent, and it's hard to debug as the serial console displays only ascii characters.
When I use Serial.print instead, mem_freq[2] shows correctly 0x120500
After Majenko's answer, I tried this:
Serial.print(0x123456 >> 16,HEX);
Serial.print(0x123456 >> 8,HEX);
Serial.print(0x123456,HEX);
Serial.print(0x00,HEX);
Serial.print(0x01,HEX);
And it outputs:
12123412345601
Is this normal ?