#include <Arduino.h>
int X[16];
int Y[16];
int c = 0;
unsigned long lm = 0;
void setup() {
DDRD |= 0b00111100;
DDRB |= 0b00001111;
PORTD &= ~0b00111100;
PORTB |= 0b00001111;
int i = 0;
for (int y = 3; y >= 0; y--) {
if ((3 - y) % 2 == 0) {
for (int x = 0; x < 4; x++) {
X[i] = x;
Y[i] = y;
i++;
}
} else {
for (int x = 3; x >= 0; x--) {
X[i] = x;
Y[i] = y;
i++;
}
}
}
}
void loop() {
if (millis() - lm >= 200) {
lm = millis();
PORTD &= ~0b00111100;
PORTB |= 0b00001111;
PORTD |= (1 << (Y[c] + 2));
PORTB &= ~(1 << X[c]);
c++;
if (c >= 16) c = 0;
}
}