#include <TimerOne.h>
void setup(void) {
Timer1.initialize(1000000); // μs
Timer1.attachInterrupt(sequencer);
DDRD |= 0xF0;
}
volatile byte seqCount = 0;
volatile byte nibbleState = 8;
volatile bool clear = false;
void sequencer(void) {
if (seqCount == 8) {
nibbleState = 8;
seqCount = 0;
}
seqCount += 1;
if (clear) {
nibbleState <<= 1;
PORTD |= nibbleState;
} else {
PORTD &= ~0xF0;
}
clear = !clear;
}
void loop(void) {
// put your main code here
}