#define CLK 13
#define DIN 11
#define CS  10
#define NUM_SEGMENTS 16

void shiftAll(byte send_to_address, byte send_this_data)
  digitalWrite(CS, LOW);
  for (int i = 0; i < NUM_SEGMENTS; i++) {
    shiftOut(DIN, CLK, MSBFIRST, send_to_address);
    shiftOut(DIN, CLK, MSBFIRST, send_this_data);
  digitalWrite(CS, HIGH);

void setup() {
  Serial.println("Please create some cool demo with this!");

  // Quick demo code: Fill the matrix with an alternating pattern
  pinMode(CLK, OUTPUT);
  pinMode(DIN, OUTPUT);
  pinMode(CS, OUTPUT);

  // Setup
  shiftAll(0x0f, 0x00); //display test register - test mode off
  shiftAll(0x0b, 0x07); //scan limit register - display digits 0 thru 7
  shiftAll(0x0c, 0x01); //shutdown register - normal operation
  shiftAll(0x0a, 0x0f); //intensity register - max brightness
  shiftAll(0x09, 0x00); //decode mode register - No decode

  // Write some data
  shiftAll(0x01, 0xaa);
  shiftAll(0x02, 0x55);
  shiftAll(0x03, 0x55);
  shiftAll(0x04, 0x55);
  shiftAll(0x05, 0x55);
  shiftAll(0x06, 0x55);
  shiftAll(0x07, 0x55);
  shiftAll(0x08, 0x55);

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