32 bit binary counter

See if this works for you, no comments so a learning exercise, hit the books. :slight_smile:

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.