Skip to content

Instantly share code, notes, and snippets.

@cho0h5
Last active September 18, 2022 08:58
Show Gist options
  • Save cho0h5/43f5c3abd41af3dfece1d530282f0977 to your computer and use it in GitHub Desktop.
Save cho0h5/43f5c3abd41af3dfece1d530282f0977 to your computer and use it in GitHub Desktop.
void setup() {
pinMode(13, OUTPUT);
OCR0A = 0xF9; // 249
TCCR0B = (1 << WGM01) | (1 << CS01); // CTC, prescale
TIMSK0 = (1 << OCIE1A); // interrupt
}
void loop() {
}
ISR(TIMER0_COMPA_vect) { // 8000hz
digitalWrite(13, digitalRead(13) ^ 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment