       digitalWrite(rankPins[manual], LOW);
 
       // poll all keys, sending MIDI events if warranted
-      rankPoll(keyPins, keyStates[manual], numKeys, manual);
+      keyPoll(keyPins, keyStates[manual], numKeys, manual);
 
       // return the drive pin to +5V (off)
       digitalWrite(rankPins[manual], HIGH);


  // read the pedals
  digitalWrite(pedalPin, LOW);
  rankPoll(pedalPins, pedalStates, numPedals, pedalChannel);
  digitalWrite(pedalPin, HIGH);
}

// define how large some things are (matrix size)
const int numKeys = 61;    // full organ manual, also length of keyPins and midiKeyNotes
const int numPedals = 32;  // full AGO 32-key pedalboard
const int numManuals = 2;  // number of manuals

const unsigned char midiKeyNotes[numKeys] = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, };
const unsigned char midiChannels[numManuals] = {1, 2, };  // Five manuals plus pedals (pedals always rank 16)
const unsigned char pedalChannel = 16;

// State of all keys in a 2D multidimensional array
bool keyStates[numManuals][numKeys] = {
  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
};

// State of all pedals in a 1D array
bool pedalStates[numPedals] = {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, };


// Convenience func to convert a boolean to the proper MIDI key velocity
