void setup()
{
  DDRD = 0xFF ;
  DDRB = 0xFF ;
  DDRC = 0xFF ;

  PORTB = 0;
  PORTC = 0;
  PORTD = 0;
}
void loop()
{
  static byte sec = 40, min = 59, hour = 23;

  sec++;

  if (sec == 60) {
    sec = 0;
    min++;
    if (min == 60) {
      min = 0;
      hour++;
      if (hour == 24) {
        hour = 0;
      }
    }
  }

  delay(1000);

  /*  PORTD = (sec/10) << 4 + sec%10 + (min%2) << 7;
    PORTB = (min/10) << 3 | (min%10) >> 1;
    PORTC = (hour/10) << 4 | (hour%10);
    delay(1000);
  */

  PORTD = (hour % 10) | (hour / 10) << 4 | ((min % 10) & 3) << 6;
  PORTB = ((min & 10) & 0b1100) >> 2 | ((min / 10) << 2) | (sec & 1 << 5);
  PORTC = ((sec % 10) >> 1) | (sec / 10) << 3;
}