void setup() {
DDRB = 0x0f;
}
void loop() {
static int bits = 0;
static unsigned long lastUpdateTime = 0;
unsigned long _now = millis();
if (_now - lastUpdateTime >= 500) {
lastUpdateTime = _now;
PORTB = bits;
bits = (bits + 1) % 16;
}
}