[PD] pduino digital outs

martin.peach at sympatico.ca martin.peach at sympatico.ca
Thu Oct 12 20:33:37 CEST 2006


I'm trying to implement the pduino using a PIC16F767.
So far I have the analog ins and digital ins working well.
In testing I find that the arduino-help patch sends digital outs as 229, low7, high7, that is, the digital out token followed by the bit pattern for the low 7 bits and then the bit pattern for the high 7 bits. On the other hand, the Pd_firmware.pde code expects the high byte first:

    if(firstInputByte) {
      // output data for pins 7-13
      for(i=7; i<TOTAL_DIGITAL_PINS; ++i) {
        mask = 1 << i;
        if( (digitalPinStatus & mask) && !(pwmStatus & mask) ) {
          // inputData is a byte and mask is an int, so align the high part of mask
          digitalWrite(i, inputData & (mask >> 7));
        }        
      }
      firstInputByte = false;
    }
    else { //
      for(i=0; i<7; ++i) {
        mask = 1 << i;
        if( (digitalPinStatus & mask) && !(pwmStatus & mask) ) {
          digitalWrite(i, inputData & mask);
        } 
      }
    }

...so which is correct?

Also the digitalWrite(i, inputData & mask) should probably be digitalWrite(i, (inputData && mask)?HIGH:LOW).

Martin






More information about the Pd-list mailing list