Connecting Encoder Channel A to Hardware Counter

Ok so after looking around those sites I think I found what I needed but I'm not sure why it won't work.

When I run the code the counter just counts up infinitely without me ever turning the motor/encoder. My only guess is that your code was based off of the ATmega128 and I'm using the ATmega328. So maybe some of the registers are different.

Any Help would be greatly appreciated,
Cory

#define ENCODER_READ 5
unsigned int encoderPos;

void setup() 
{  
  Serial.begin(19200);
  counterStart();
}

void loop()
{
encoderPos = getCount();
Serial.println(encoderPos);
}

// call this to initialize the counter
void counterStart()
{
  // hardware counter setup, see p. 107 for info on the 16-bit Timer1 Timer/Counter
  TCCR1A=0;                              // reset timer/countern control register A
  TCCR1B=0;                              // reset timer/countern control register B
  TCNT1=0;                               // initialize the counter value to 0; this register holds the current count
  
  // set timer/counter1 hardware as a counter; it counts events on pin Tn (Arduino pin 5)
  // normal mode, wgm10 .. wgm13 = 0, see p. 131, table 13-4
  TCCR1B = TCCR1B | 7; // Counter Clock source = pin Tn (Arduino pin 5) , start counting now
  // 7 in binary is 0111; OR-ing will set CS10,11,12 to 1's
  // External clock source on Tn pin. Clock on rising edge., see table 13-5, p. 132
}


// call this to get the current count
unsigned int getCount()
{
  unsigned int count;                          // this variable returns the current encoder count from the counting register
  TCCR1B = TCCR1B & ~7;                        // Gate Off  / Counter Tn stopped, see table 13-5, p. 132; we need to disable counting just prior to our read
                                               // this operation clears the bits (CS10,11,12)
 
  count = TCNT1;                               // read the counting register
  TCCR1B = TCCR1B | 7;                         // re-start counting by resetting the bits (CS10,11,12)
  return count;                                // return the retreived count to the calling function
}