digitalReadNibble()
[Digital I/O]
unsigned char digitalReadNibble(unsigned short a, unsigned char b, unsigned char c, unsigned char d);Description
Reads the value from the specified nibble (4 bits) of the Custom Element pins.
Parameters
a: the pin of the most significant bit of the nibble
(MSB).
b: the pin of the second most significant bit of the
nibble.
c: the pin of the second least significant bit of the
nibble.
d: the pin of the least significant bit of the nibble
(LSB).
Returns
The value of the nibble (0-15) as an 8-bit value.
Example Code
The code reads the value of a nibble from the Custom Element pins 3, 4, 5, and 6.
void setup() {
pinLabel(3, "IN"); // sets the pin 3 label to "IN" (by default will be an input)
pinLabel(4, "IN"); // sets the pin 4 label to "IN" (by default will be an input)
pinLabel(5, "IN"); // sets the pin 5 label to "IN" (by default will be an input)
pinLabel(6, "IN"); // sets the pin 6 label to "IN" (by default will be an input)
}
void loop() {
unsigned char nibble = digitalReadNibble(3, 4, 5, 6); // reads the value of the nibble from the pins 3, 4, 5, and 6
}Notes and Warnings
If the pin is defined as three-state and the ground pin isn’t
connected to anything, digitalReadNibble() will always
return 15.
