Toggle four relays on/off based on bitmap stored in uint8_t
Use a loop to eliminate all that copy-pasta and get rid of some superfluous tests, branches and hard-coded constants:

void relayToggle(uint8_t relayBitmap)
{
    for (int r = 1; r &lt;= 4; ++r)
    {
         if (relayBitmap &amp; 1)
             relayOn(r);
         else
             relayOff(r);
         relayBitmap &gt;&gt;= 1;
    }
}