   unsigned long now = millis();
   if (now > lastIncrement + 20)
   {
-    valueToDisplay++;
+    valueToDisplay = (valueToDisplay + 1) % 10000;
     lastIncrement = now;
   }
+
+  digitalWrite(ledPin, (now % 200 == 0) ? HIGH : LOW);
 }
 
 void writeValue(byte digit, byte value)


void setup()
{
  Serial.begin(9600);
  Serial.println();
  
  pinMode(outputDisabledPin, OUTPUT);
  pinMode(registerClockPin, OUTPUT);  
  pinMode(whichSegmentData, OUTPUT);
  pinMode(segmentShiftRegisterClockPin, OUTPUT);  
  pinMode(whichDigitData, OUTPUT);
  pinMode(shiftRegisterClockPin, OUTPUT);

  digitalWrite(outputDisabledPin, LOW);

  writeValue(0, 0);
  valueToDisplay = 0;
}

void loop()
{
  // Arduino pow function is approximage and sometimes will end up rounding down when casting to int
  int place = pow(10, 3 - segmentIndex) + 0.5f;
  int segmentValue = (valueToDisplay / place) % 10;


#include <arduino.h>

// led on device
const int ledPin = 13;
const int hackPin = 8;

// shared pins
const int outputDisabledPin = 3;
const int registerClockPin = 11;

// segment pins
const int whichSegmentData = 9; 
const int segmentShiftRegisterClockPin = 10;

// digit pins
const int whichDigitData = 6;
const int digitShiftRegisterClockPin = 5;

const int segTop = (1 << 7);
const int segDot = (1 << 1);
const int segMiddle = (1 << 5);
const int segBottomRight = (1 << 4);
const int segBottomLeft = (1 << 2);
const int segBottom = (1 << 3);
const int segTopLeft = (1 << 6);
const int segTopRight = (1 << 0);

byte segmentIndex = 0;
int valueToDisplay = 0;
