int Array to Byte

Hello

How to convert int array to byte.

for eg. b[8]={0,0,0,0,1,1,1,1};

I want to convert into byte so that its value will be

uint16_t p=0b00001111

Please answer it as soon as possible.

The bitWrite() function does that.

int b[8]={0,0,0,0,1,1,1,1};
uint16_t p = 0;
for (int i=0; i<8; i++)
    p = (p<<1) | (bool)b[i];