user15493: I have found an Arduino function which converts a 2-bytes-long-value to a binary value.
e.g. I call sendCommand(0x05) And it gives me an output:
00000101
void sendCommand(unsigned long command){
  for (unsigned long  mask = 1UL << (7);  mask;  mask >>= 1) {

    if (command & mask) {

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

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

my Problem is, that I want to have the Least significant bit first. How do I have to adjust this function to achieve this?
e.g.
sendCommand(0x05)
shall give an output:
10100000

user2881: void sendCommand(unsigned long command){
  for (unsigned long  mask = 1UL; mask<256UL;  mask <<= 1) {

    if (command & 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.

15493: <p>I have found an Arduino function which converts a 2-bytes-<code>long</code>-value to a binary value.</p>

<p>e.g. I call <code>sendCommand(0x05)</code> And it gives me an output:</p>

<p><code>00000101</code></p>

<pre><code>void sendCommand(unsigned long command){
  for (unsigned long  mask = 1UL &lt;&lt; (7);  mask;  mask &gt;&gt;= 1) {

    if (command &amp; mask) {

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

    Serial.print( "0" );
    }
  }
}
</code></pre>

<p>my Problem is, that I want to have the Least significant bit first. How do I have to adjust this function to achieve this?</p>

<p>e.g.
<code>sendCommand(0x05)</code>
shall give an output:</p>

<p><code>10100000</code></p>
 2881: <pre><code>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" );
    }
  }
}
</code></pre>

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