N
N
nikther2014-05-18 19:37:39
Arduino
nikther, 2014-05-18 19:37:39

Arduino bit number from list of bits?

The bottom line is, there is a list of
unsigned char bits DraftByteData[][] = {
{0, 1, 0, 1, 1, 0, 1, 1, 0},
{0, 1, 1, 1, 0, 1, 0 , 1, 0}
}
from it it is necessary to make
unsigned char byteData[] = {
B0101110110, B011101010
}
how can this be implemented or in what direction to look for functions for this kind of operations

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Vershinin, 2014-05-18
@nikther

unsigned byte *resultData = new byte[size]; //size - количество массивов в массиве draftByteData
unsigned byte tmp = 0, i, j;

for(i = 0; i < size; ++i)
{
    for(j = 0; j < 8; ++j)
    {
        tmp |= draftByteData[i][j];
        tmp <<= 1;
    }
  
    resultData[i] = tmp;
    tmp = 0;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question