Binary Clock

You don't need to use low level direct port i/o to derive binary values and drive pins. The following example uses the Arduino bitRead function to convert from decimal to binary. The advantage of doing this using the arduino pins is that any group of sequential pins can be used for each of the digits.

Mem, of course your code is better. I am still learning too. It might not be obvious to the OP but by using the call to millis() you have also avoided the problem of inaccuracy by using the System time rather than a delay loop.