See if this works for you, no comments so a learning exercise, hit the books. ![]()
void setup()
{
 DDRD = B11111000;
}
void loop()
{
 int interval = 400;
 static unsigned long timer;
 static byte counter;
Â
 if(millis() - timer > interval)
 {
  timer += interval;
  PORTD = counter << 3 & B11111000;
  if(++counter > 31)
   counter = 0;
 } Â
}
BTW: It's a 5 bit counter, a 32 bit counter would count to 4294967296.