void loop() not looping

Hello. I am trying to get this working: A Touchless 3D Tracking Interface - Make: However, when I view the console, the loop method does not seem to be looping, and only prints out two values instead of three. Here is the sketch:

// By Kyle McDonald
// From the instructables project at:
// http://www.instructables.com/id/DIY-3D-Controller/

#define resolution 8
#define mains 60 // 60: north america, japan; 50: most other places

#define refresh 2 * 1000000 / mains

void setup() {

  // unused pins are fairly insignificant,
  // but pulled low to reduce unknown variables
  for(int i = 2; i < 14; i++) {
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);

  for(int i = 8; i < 11; i++)
    pinMode(i, INPUT);


void loop() {  
  Serial.print(time(8, B00000001), DEC);
  Serial.print(" ");
  Serial.print(time(9, B00000010), DEC);
  Serial.print(" ");
  Serial.println(time(10, B00000100), DEC);


long time(int pin, byte mask) {
  unsigned long count = 0, total = 0;
  while(checkTimer() < refresh) {
    // pinMode is about 6 times slower than assigning
    // DDRB directly, but that pause is important
    pinMode(pin, OUTPUT);
    PORTB = 0;
    pinMode(pin, INPUT);
    while((PINB & mask) == 0)
  return (count << resolution) / total;

extern volatile unsigned long timer0_overflow_count;

void startTimer() {
  timer0_overflow_count = 0;
  TCNT0 = 0;

unsigned long checkTimer() {
  return ((timer0_overflow_count << 8) + TCNT0) << 2;

What's with the whole timer business. Why not just use millis or micros to count time?

As I said above, I'm following a guide for the code, so the default code that the project suggested you use uses this method.

Are you certain of all the wiring connections? Try switching the input from the pin/panel which is not giving a reading with one that is. For example if the third value from pin 10 is always zero, but you get the first value from pin 8, switch the leads around and see if the zero value goes with the wire, or stays with the pin.

Just tried switching the pins, and the loop seems to be getting stuck on pin 10:

 while((PINB & mask) == 0) {
      Serial.print("in time ");

Can you run a simple digitalRead test on pin 10 and see if it responds to 5v and ground.