Serial_byte help

An example:

byte ourByte = 0b00000010;

void setup()
{
   Serial.begin(115200);
   // read the second from the right bit (bit 1) of the byte ourByte   
   Serial.print("bit 1 of ourByte = ");
   Serial.println(bitRead(ourByte, 1)); 
}

void loop()
{
  
}

Output:

bit 1 of ourByte = 1

1 Like