Port manipulation in Arduino using byte value
What is the problem in this code?


No problem, it does change the bits of port D and B from 0B10101000 and 0B00101010 to 0B01010000 and 0B00010101 respectively.

However, microseconds later loop() runs again and changes them back to  0B10101000 and 0B00101010 for a full second. 

To better see what's happening, add a second delay(1000); statement, placing it just before the closing brace.