I will have to start with an apology because I am unsure of the terminology, corrections welcome.
I am concatenating a number of HIGH/LOW flags into a bit array
I then use this bit array as the variable in a switch case
I then use Binary formatting (e.g. B10101111) for the case statements against which the variable will be compared
This works fine for up to 8 flags. But Binary formatting will not work for more than 8bit
I have generated the following code to perform Binary formatting for up to 16bits
In this example it generates the bit array 11001111101 = 1661
Can anybody tell me a more convenient/elegant way of doing this?
By convenient I mean something closer to typing in B11001111101
void setup() {
Serial.begin(9600);
}
void loop() {
unsigned int x = unsigned((B11001111 * 256UL) + (B101 << 5)) >> 5;
Serial.println(x);
}