boolean array

Great, thank you so much guys I didn’t finished yet but at this step it’s okay voilà how my code looks like:

byte received[6];
int i;

void setup() {
Serial.begin(9600);// put your setup code here, to run once:
}

void loop() {
i = 0 ;
while ( Serial.available() > 0 ) {
received = Serial.read();

  • Serial.println("\n");*
    _ Serial.println(received*);// damn this an ascii value*_
    _ Serial.println((byte)received - 48);
    * byte value; // given byte value*
    * boolean bitArray[8];
    value = received - 48;
    // examining bits 0…7 (0 is LSB = least significant bit)
    for (int bit = 0; bit <= 7; bit++) {
    if (value & (1 << bit)) {
    bitArray[bit] = 1; // add true to array*

    * } else {
    bitArray[bit] = 0; // add alse to array*

    * }
    }
    for (int i = 7; i >= 0; i–) {
    Serial.print(bitArray);
    delay(500);
    }
    i++;*_

* }*
}

my code looks like:

I’d bet a box of donuts that it doesn’t. Read the stickies at the top of the forum and try again.

Ohlala!! :o no you didn’t, i am very gratefulbecause you’re here guys, so here is the final code

boolean bitArray[48];

void setup() {
  Serial.begin(9600);
}

void loop() {
  int i= 0;
  
  byte received;

  while ( Serial.available() > 0 && i < 6) {
    //  if(i==6)

    received = Serial.read();
    //Serial.println("\n");
    //Serial.println(received);
    for (int bit = 0; bit <= 7; bit++) {
      if (received & (1 << bit)) {
        bitArray[bit + i * 8] = 1; // add true to array
      } else {
        bitArray[bit + i * 8] = 0; // add alse to array
      }

      Serial.print(bitArray[bit + i * 8]);
    }
    i++;
 }
}

Why does bitArray have 48 elements when only 6 are needed ?

UKHeliBob: Why does bitArray have 48 elements when only 6 are needed ?

I for one will congratulate OP on getting a solution that he understands, and that works.

Of course storing the original bytes and picking bits out of them when needed, is a more space efficient solution.