Convert Long to binary - least signifant bit first
void sendCommand(unsigned long command){
  for (unsigned long  mask = 1UL; mask&lt;256UL;  mask &lt;&lt;= 1) {

    if (command &amp; mask) {

    Serial.print( "1" );
    } else {

    Serial.print( "0" );
    }
  }
}


PS a long is actually 4 bytes long. But your code only uses 1 byte of it.