 
   for (index = PIN_HELM_MAT_ROW; index < PIN_HELM_MAT_ROWS; index++)
   {
+    pinMode(index, OUTPUT);
     digitalWrite(index, HIGH); // pull these up to 5V so current cannot flow
   }
 }

  uint16_t matrix = 0;
  uint8_t row = 0, col = 0;

#ifdef DEBUG
  Serial.println(F(" => matrix"));
#endif

  for (row = PIN_HELM_MAT_ROW; row < PIN_HELM_MAT_ROWS; row++)
  {
    digitalWrite(row, LOW); // turn on the active-low row

    for (col = PIN_HELM_MAT_COL; col < PIN_HELM_MAT_COLS; col++)
    {
      boolean switchState = !digitalRead(col); // get inverted result
      matrix <<= switchState; // and shift it onto the matrix

#ifdef DEBUG
      Serial.print(F("\t"));
      Serial.print(switchState);
#endif
    }

    digitalWrite(row, HIGH); // turn off the active-low row

#ifdef DEBUG
    Serial.println();
#endif
  }

#ifdef DEBUG
  Serial.println();
#endif

  return (matrix);
}

int16_t helmGetAdjustment(uint8_t high, uint8_t low, int8_t adj) // get control input
{
  switch (high ? HIGH : (low ? LOW : NEUTRAL)) // high trumps low
  {

{
  // get the matrix state used in the pitch/roll/yaw masks below
  uint16_t helm = helmReadMatrix();

  // update control surface inputs
  // the MASKED_ contants have "helm & DIR_MASK_x" format for convenience
  pitchAdjust = helmGetAdjustment(MASKED_PITCH_U, MASKED_PITCH_D, pitchAdjust);
