How to Use Word() Function in Arduino?

ArduinoHardwareSoftware & Coding

The word() function converts a variable of any data type to the word data type. It is essentially a cast function.

Syntax

The syntax is −

word(var)

Where var is a variable of any datatype.

Alternatively, you can also construct a word by specifying two bytes, the higher byte and the lower byte.

Syntax

The syntax is −

word(highByte, lowByte)

For instance, word(2,5) will return 517 (2 is 0b00000010 and 5 is 0b00000101; word(2,5) will return 0b0000001000000101, which equals 517).

You can try out other combinations of characters and data types. You can read more about the word function from Arduino’s official documentation here.

raja
Updated on 30-Jul-2021 15:08:15

Advertisements