int ledState;
int ledPin = 4;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
cli();
TCCR1A = 0;
TCCR1B = 0;
TCCR1B |= B00000100;
TIMSK1 |= B00000010;
OCR1A = 31250;
sei();
}
void loop() {
// put your main code here, to run repeatedly:
}
ISR(TIMER1_COMPA_vect){
TCNT1 = 0;
ledState = !ledState;
digitalWrite(ledPin,ledState);
}