I'm not sure what this means
"Create a union to make the long and a 4 byte array occupy the same space. Assign the long, and send the 4 byte array, using Serial.write(buf, len) (where buf is the 4 byte array and len is 4).
Receive the 4 bytes, and place in the array, and use the long."
Here is my first attempt to do this. "Long" is surely not the right operator to use here. I need something that will concatenate the four byte array into the key which should be 0xBF30CF, which I will send to the IRsend.sendNEC function.
Here is my first try to construct and send the array. I'm trying to use the Serial.print() function to see what the concatenated array will look like. I would like to see "BF30CF" on the serial monitor, but instead I get gibberish.
I appreciate everyone's patience here, I know these are basic, ignorant questions.
#include <IRremote.h>
IRsend irsend;
byte array[4] = {0x00, 0xBF, 0x30, 0xCF};
unsigned long key = 0;
void setup()
{
Serial.begin(9600);
}
void loop() {
Serial.write(array, 4);
key = long(array);
Serial.print("\t");Serial.println(key, HEX);
/*
irsend.sendNEC(0xBF30CF, 32); // TV power code
delay(2000);
irsend.sendNEC(message1, 32); // TV power code
*/
delay(2000);
}
which gives me on the serial monitor:
?0I 102