volatile bool status=false;
#define FCPU 16000000 //CPU Clock Speed
#define TD .5 //500ms delay before counter overflow
#define PRESCALER 1024
#define RELOAD (65536-FCPU*TD/PRESCALER)
void setup() {
pinMode(3, OUTPUT);
digitalWrite(3,status);
cli(); //Disable Global Interrupt
TCNT1 = RELOAD; //load the TCNT1 with RELOAD value for 500ms delay //for normal mode operation and pre-scalar of 1024
TCCR1A = 0x00; TCCR1B = 0b00000101;
bitSet(TIMSK1, TOIE1);
sei(); //Enable Global Interrupt
}
void loop() {
// There is nothing here
}
ISR(TIMER1_OVF_vect){
TCNT1 = RELOAD;
status=!status;
digitalWrite(3,status);
}