byte max7219_REG_digit0 = 0x01;
byte matrix_data = B00111100;

void setup() {
 Serial.begin(9600);
 byte i = 8;  //variabel untuk menyimpan nilai i
 byte mask;   
 while(i > 0) {
 Serial.print("loop ke ");
 Serial.println(i);
mask = 0x01 << (i - 1);// create masking bit, 
 // starting from Left
 Serial.println(matrix_data,BIN);
 Serial.println(mask,BIN);
 if (matrix_data & mask){// Compare masking bit to corresponding bit
 Serial.println("1");// If corresponding bit is 1,
 // print 1
 }
 else{
 Serial.println("0");// If corresponding bit is 0,
 // print 0
 }
 --i;// Move to next bit
 }
}

void loop() {
  // put your main code here, to run repeatedly:

}