Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created July 19, 2020 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/5a7e8e80e1b16d8ec155957587872179 to your computer and use it in GitHub Desktop.
Save JeffersGlass/5a7e8e80e1b16d8ec155957587872179 to your computer and use it in GitHub Desktop.
int ledpin = PORTB5;
void setup() {
// put your setup code here, to run once:
DDRB = _BV(ledpin); //Set up LED pin as output
Serial.begin(115200);
TCCR1A = _BV(COM1A0); //Mode will be CTC; WGM12 is in B register
TCCR1B = _BV(WGM12) | _BV(CS12) | _BV(CS10); //Set up x1024 prescaler
OCR1A = 0x3333;
TIMSK1 = _BV(OCIE1A); //Enable overflow interrupt
interrupts(); //Enable interrupts globally
}
void loop() {
}
ISR(TIMER1_COMPA_vect){ //Timer1 Comp Interrupt
Serial.println("Hello!");
PORTB ^= _BV(ledpin);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment