Basic Library
Digital I/O
Analog I/O
Advanced I/O
Time
Math
Trigonometry
Random Numbers
Bits and Bytes
Interrupts
Serial Comm.
Standard Library
Ethernet
Ethernet (Server)
Ethernet (Client)
Servo Motor
Character LCD
SPI
I2C (Wire)
SD Card
SD (File Operations)
Periodic Operation
Clock (RTC)
Bits and Bytes Operations
This library is used for bits and bytes operations.
lowByte
- Description
- Extracts the low-order (rightmost) byte of a variable (e.g. a word). For example, it extracts 0x34 when given a parameter of 0x1234.
- Syntax
- lowByte(x)
- Parameters
- x: A value of any type
- Returns
- 1 byte (unsigned char)
highByte
- Description
- Extracts the high-order (leftmost) byte of a word. For example, extracts 0x12 when given a parameter of 0x1234.
- Syntax
- highByte(x)
- Parameters
- x: A value of any type
- Returns
- 1 byte (unsigned char)
bitRead
- Description
- Reads the specified bit.
- Syntax
- bitRead(x, n)
- Parameters
- x: A value of any type
n: The position of the bit to be read - Returns
- The value of the bit (0 or 1)
bitWrite
- Description
- Writes the specified bit.
- Syntax
- bitWrite(x, n, b)
- Parameters
- x: A value of any type
n: The location of the bit to write
b: The value to write to the bit (0 or 1) - Returns
- None
bitSet
- Description
- Sets (writes 1 to) the specified bit.
- Syntax
- bitSet(x, n)
- Parameters
- x: A value of any type
n: The location of the bit to be set to 1 - Returns
- None
bitClear
- Description
- Clears (writes 0 to) the specified bit.
- Syntax
- bitClear(x, n)
- Parameters
- x: A value of any type
n: The location of the bit to be set to 0 - Returns
- None
bit
- Description
- Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.).
- Syntax
- bit(n)
- Parameters
- n: The location of the bit that will be calculated
- Returns
- The value of the bit
Sample Program
Sample for lowByte and highByte.
#include <Arduino.h>
void setup()
{
uint16_t data = 0x1234;
Serial.begin(9600);
while(!Serial.available()); // wait to key press.
Serial.println(data, HEX);
Serial.println(lowByte(data), HEX);
Serial.println(highByte(data), HEX);
}
void loop()
{
}