#include <avr/io.h>
#include <Arduino.h>
int main(void)
{
DDRB |= (1 << 5); // Set LED as output
TCCR1B |= (1 << CS12 ); // Set up timer with the prescaler of 256
TCCR1B |= (1 << WGM12); // Turn on the CTC mode for Timer
OCR1A = 31249; // Set CTC compare value to 5Hz at 16 MHz AVR clock , with a prescaler of 256
while (1)
{
if (TIFR1 & (1<<OCF1A)) //Check if Compare Match
//F here means flag
{
PORTB ^= (1 << 5); // Toggle the LED
TIFR1 |= (1<<OCF1A); //Clear the flag
}
}
}
//this configuration does not need to use the
//the pin 13 also controls the built in LED (L)