Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save futureshocked/8d6b34e7e0abd0e121c5ff10a74cf483 to your computer and use it in GitHub Desktop.
Save futureshocked/8d6b34e7e0abd0e121c5ff10a74cf483 to your computer and use it in GitHub Desktop.
convert the 4-bit code in the dip_switch array into an integer
byte encodebool(boolean* arr)
{
byte val = 0;
for (int i = 0; i<4; i++)
{
val <<= 1;
if (arr[i]) val |= 1;
}
return val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment