hello.i have 2 byte .example a and b.and i want to combine this bytes in x(word) variable.or how can i do this shortly.i try to use
byte a;
byte b;
word(x);
word(a,b);
but it doesnt work always x =0
can u help me pls
hello.i have 2 byte .example a and b.and i want to combine this bytes in x(word) variable.or how can i do this shortly.i try to use
byte a;
byte b;
word(x);
word(a,b);
but it doesnt work always x =0
can u help me pls
Try this:-
void setup()
{
Serial.begin(115200);
byte a = 2; // Will be high byte
byte b = 3; // Will be low byte
word x = word(a, b);
Serial.println(x, BIN); // Prints: "1000000011"
}
void loop(){}
Edit: Incidentally, a 'word' variable is just an 'unsigned int', so this is the same:-
void setup()
{
Serial.begin(115200);
byte a = 2; // Will be high byte
byte b = 3; // Will be low byte
unsigned int x = word(a, b);
Serial.println(x, BIN); // Prints: "1000000011"
}
void loop(){}
thank you .its working now.thanks a lot