title: How do I send arduino a firmata command to turn on a pin
body: <p>I'm trying to implement the firmata protocol and having a bit of a difficult time deciphering the spec for writing digital pins:</p>
  
  <p>I have noted the following parts of the <a href="http://firmata.org/wiki/V2.3ProtocolDetails" rel="nofollow">spec of Firmata 2.3</a></p>
  
  <pre><code>* type                command  channel    first byte            second byte 
  ------------------------------------------------------------------------------
  * digital I/O message   0x90   port       LSB(bits 0-6)         MSB(bits 7-13)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>/* two byte digital data format, second nibble of byte 0 gives the port number (e.g. 0x92 is the third port, port 2)
   * 0  digital data, 0x90-0x9F, (MIDI NoteOn, but different data format)
   * 1  digital pins 0-6 bitmask
   * 2  digital pin 7 bitmask 
   */
  </code></pre>
  
  <p>I'm having some difficulty interpreting the spec.  I've looked at other implementations, but haven't been able to see the relationship between the spec and implementation.</p>
  
  <p>So let's say I am wanting to turn on the Arduino LED (pin 13), I know it will be on the second port, port 1, so the first byte will be <code>#{91}</code>.   </p>
  
  <p>I'm getting confused about the bitmask for the second two bytes though.  I know what a bitmask is, so I want to enable the right bit for the pin.  </p>
  
  <ul>
  <li><p>Why is the bitmask so large for the digital pins?  I'm familiar with using bitmasks on the digital outputs of PLCs, which seems much different (one pin, one bit)</p></li>
  <li><p>My thought is that pin 13 would be the 7th pin on port 1.  Since I don't care about the other pins, I would mark the pin in the 2nd byte #{40} and I don't need any pins set for the third byte #{00}?  </p></li>
  </ul>
  
  <p>I don't think my interpretation of the bitmasks is correct, and it's probably where my error is</p>
  
  <p>Am I on the right track for this?  Is this the right command for setting a pin high or low?</p>