/* Transmit the first 'length' bits of the integer 'code'. The bits are sent from MSB to LSB, i.e., first the bit at position length-1, then the bit at position length-2, and so on, till finally the bit at position 0.  */
void send(unsigned long protocol_id, unsigned long pulse_length, unsigned long repeat, unsigned long pin, unsigned long value, unsigned int length)
/* Transmit the first 'length' bits of the integer 'code'. The bits are sent from MSB to LSB, i.e., first the bit at position length-1, then the bit at position length-2, and so on, till finally the bit at position 0.  */
void send(unsigned long protocol_id, unsigned long pulse_length, unsigned long repeat, unsigned long pin, unsigned long value, unsigned int length)
{
    for (int i = length-1; i >= 0; i--) {
      if (value & (1L << i))
        transmit(p.one, p.invertedSignal, pulse_length, pin);
      else
        transmit(p.zero, p.invertedSignal, pulse_length, pin);
    }
    transmit(p.syncFactor, p.invertedSignal, pulse_length, pin);
  }
}