volatile int currentLED = 0;//
int ledPins[] = {8, 9, 10, 11};
ISR(TIMER1_COMPA_vect)
{
for(int i = 0; i < 4; i++)
{
digitalWrite(ledPins[i], LOW);
}
digitalWrite(ledPins[currentLED], HIGH);
currentLED++;
if(currentLED >= 4)
{
currentLED = 0;
}
}
void setup()
{
for(int i = 0; i < 4; i++)
{
pinMode(ledPins[i], OUTPUT);
}
noInterrupts();
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 15624;
TCCR1B |= (1 << WGM12);
TCCR1B |= (1 << CS12) | (1 << CS10);
TIMSK1 |= (1 << OCIE1A);
interrupts();
}
void loop()
{
}