diff --git a/arduino/ledCycleInterrupt/ledCycleInterrupt.ino b/arduino/ledCycleInterrupt/ledCycleInterrupt.ino new file mode 100644 index 0000000..05475dd --- /dev/null +++ b/arduino/ledCycleInterrupt/ledCycleInterrupt.ino @@ -0,0 +1,48 @@ +// Arduino timer CTC interrupt example +// +// avr-libc library includes +#include +#include +#define LEDPIN 8 + +volatile byte seconds; + +void setup() +{ + pinMode(LEDPIN, OUTPUT); + // initialize Timer1 + cli(); // disable global interrupts + TCCR1A = 0; // set entire TCCR1A register to 0 + TCCR1B = 0; // same for TCCR1B + + // set compare match register to desired timer count: + OCR1A = 15624; + + // turn on CTC mode: + TCCR1B |= (1 << WGM12); + + // Set CS10 and CS12 bits for 1024 prescaler: + TCCR1B |= (1 << CS10); + TCCR1B |= (1 << CS12); + + // enable timer compare interrupt: + TIMSK1 |= (1 << OCIE1A); + + // enable global interrupts: + sei(); +} + +void loop() +{ +// main program +} + +ISR(TIMER1_COMPA_vect) +{ + seconds++; + if(seconds == 10) + { + seconds = 0; + digitalWrite(LEDPIN, !digitalRead(LEDPIN)); + } +} diff --git a/schematics/ledstrip.fzz b/schematics/ledstrip.fzz new file mode 100644 index 0000000..2c394a1 Binary files /dev/null and b/schematics/ledstrip.fzz differ