Driving 7-segment displays
I would rename loop to demo.
The spec says that the value argument to digitalWrite may only be HIGH or LOW, and it doesn't spell out their bit representations. Even though your code works (I presume), it is better to stick with the spec.
LEDP never changes. You don't have to invert each individual bit in the loop. It looks better to invert the whole bitmap at once:

if (LEDP == LOW) {
    bitmap ^= 0xff;
}

Now the body of display7 loop could be streamlined to

for (uint8_t i=0; i&lt;8; ++i) {
    digitalWrite(displayPins[i], (bitmap &amp; 0x01)? HIGH: LOW);
    bitmap &gt;&gt;= 1;
}


Notice that segment and state disappear altogether.