#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

// misc

#define OUTPUT             1
#define INPUT              0

int main (void) {

  // set up directions 
  DDRA = (OUTPUT << PA0 | INPUT << PA1 |INPUT << PA2 |INPUT << PA3 |INPUT << PA4 |INPUT << PA5 |INPUT << PA6 |INPUT << PA7);
  DDRB = (INPUT << PB0 | INPUT << PB1 |INPUT << PB2 |INPUT << PB3 |INPUT << PB4 |INPUT << PB5 |INPUT << PB6 |INPUT << PB7);
  DDRC = (INPUT << PC0 | INPUT << PC1 |INPUT << PC2 |INPUT << PC3 |INPUT << PC4 |INPUT << PC5 |INPUT << PC6 |INPUT << PC7);
  DDRD = (INPUT << PD0 | INPUT << PD1 |INPUT << PD2 |INPUT << PD3 |INPUT << PD4 |INPUT << PD5 |INPUT << PD6 |INPUT << PD7);        

  // set prescaler to /1
  TCCR1B = 0x01;
  
  // set interrupt mask register 
  TIMSK|=(1<<TOIE1);  
  
  // turn interrupts on
  sei();
  
  // chase tail
  while(1);

}

SIGNAL (SIG_OVERFLOW1) {
 PORTA ^= 0x01; //toggle portA0
}
