Skip to content

Instantly share code, notes, and snippets.

Created February 10, 2018 07:20
Show Gist options
  • Save anonymous/5bdf6395416f4f497754290b5cbf7bb7 to your computer and use it in GitHub Desktop.
Save anonymous/5bdf6395416f4f497754290b5cbf7bb7 to your computer and use it in GitHub Desktop.
AVR sketch
#include <avr/io.h>
#include <stdlib.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
int a;
void setup() {
cli();
a = 0;
TCCR1A = 0;
TCCR1B = (1 << WGM12) | (1 << CS10);
TCNT1 = 0;
OCR1A = 2022;
TIMSK1 |= (1 << OCIE1A);
DDRB = _BV(PINB4);
sei();
}
ISR(TIMER1_COMPA_vect) {
PORTB |= _BV(PINB4);
int i = 5;
while (i-- > 0)
__asm__("nop\n\t");
PORTB ^= _BV(PINB4);
}
int main(void) {
setup();
for (;;) {
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment