#define DIN 8
#define CLK 9
#define LOAD 10

void load_data(uint16_t address, uint16_t data) {
  uint16_t data_register = (address << 8) | data;
  digitalWrite(LOAD, LOW);
  //delay(1);
  for (int r = 0; r < 16; r++) {
    if (data_register & 0x01) {
      digitalWrite(DIN, HIGH);
    }
    else {
      digitalWrite(DIN, LOW);
    }
    data_register = data_register >> 1;
    //delay(1);
    digitalWrite(CLK, HIGH);
    //delay(1);
    digitalWrite(CLK, LOW);
  }
  //delay(2);
  digitalWrite(LOAD, HIGH);
}



void setup() {
  pinMode(DIN,  OUTPUT); // DIN
  pinMode(CLK,  OUTPUT); // CLK
  pinMode(LOAD, OUTPUT); // LOAD
  digitalWrite(LOAD, HIGH);
  digitalWrite(CLK, LOW);
}

void loop() {
  load_data(0b00001001,0b11111111);
  load_data(0b00000001,0);
  load_data(0b00000010,8);
  load_data(0b00000011,9);
  load_data(0b00000100,10);
  load_data(0b00000101,11);
  load_data(0b00000110,12);
  load_data(0b00000111,13);
  load_data(0b00001000,14);

  delay(1000);

  load_data(0b00001001,0x00);
  load_data(0b00000001,0b11111111);
  load_data(0b00000010,0b11111111);
  load_data(0b00000011,0b11111111);
  load_data(0b00000100,0b11111111);
  load_data(0b00000101,0b11111111);
  load_data(0b00000110,0b11111111);
  load_data(0b00000111,0b11111111);
  load_data(0b00001000,0b11111111);

  load_data(0b00001010,0x0f); // Intensity
  delay(1000);
  load_data(0b00001011,4);
  delay(1000);
  load_data(0b00001011,7);
  delay(1000);
}
MAX7219 7 SegmentBreakout