Matrix keyboard to control voltage output MCP4725

I have a Matrix piano keyboard connected to arduino and want to output 1v/oct + GATE to a synthesizer via the MCP4725 DAC.

I have some code which generates a number (1-49) for each key pressed and I want this to select the corresponding DAC value from 'DACpitches' and output to the DAC along with a GATE from one of the analog pins

Any guidance appreciated

#include <Keypad.h>
#include <stdlib.h>
#include <Wire.h>//Include the Wire library to talk I2C
#include <Adafruit_MCP4725.h>

//This is the I2C Address of the MCP4725, by default (A0 pulled to GND).
#define MCP4725_ADDR 0x60   

Adafruit_MCP4725 dac;

#define LED 13    // Arduino Board LED is on Pin 13
#define GATE 12 // Use Pin 12 to output GATE signal
//#define GATECHK 1 // Use Pin A1 to read the voltage of the GATE signal, used for debugging

  int DACnum = 0;
  int LEDval = LOW;
  int GATEval = LOW;
//  int gateVoltage = 0; // used for debugging

//number of rows on the keypad
//number of columns on the keypad
const byte numRows= 6; 
const byte numCols= 9; 


//Code that shows the the keypad connections to the arduino terminals
byte colPins[numCols] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; //Rows 0 to 3
byte rowPins[numRows]= {A0, A1, A2, A3, A4, A5}; //Columns 0 to 3


//keymap defines the key pressed according to the row and columns just as appears on the keypad
byte keymap[numRows][numCols]=
{
{1, 7, 13, 19, 25, 31, 37, 43, 49},
{2, 8, 14, 20, 26, 32, 38, 44},
{3, 9, 15, 21, 27, 33, 39, 45},
{4, 10, 16, 22, 28, 34, 40, 46},
{5, 11, 17, 23, 29, 35, 41, 47},
{6, 12, 18, 24, 30, 36, 42, 48},

};


// DAC = 4096/5 V/12 (for 1V per Octave) = 67.9 per step
int DACpitches[49] =
{
68, 478, 887, 1297, 1707, 2116, 2526, 2935, 3345,
137, 546, 956, 1365, 1775, 2185, 2594, 3004,
205, 614, 1024, 1434, 1843, 2253, 2662, 3072,
273, 683, 1092, 1502, 1911, 2321, 2731, 3140,
341, 751, 1161, 1570, 1980, 2389, 2799, 3209,
410, 819, 1229, 1638, 2048, 2458, 2867, 3277,

};



//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup()
{
  // initialize the serial communication:
  Serial.begin(115200);

  pinMode(LED, OUTPUT); // Set LED pin to output
  pinMode(GATE, OUTPUT); // Set GATE pin to output
  
  Wire.begin();
  dac.begin(0x60);

}

//If key is pressed, this key is stored in keyPadNum variable
//If key is not equal to NO_KEY, then this key is printed out
//if count=17, then count is reset back to 0 (this means no key is pressed during the whole keypad scan process
void loop()
{
  
  
  byte KeyPadNum = myKeypad.getKey(); 

  // = use KeyPadNum to index DACpitches 
  byte DACnum = DACpitches[KeyPadNum];
  
  if (KeyPadNum != NO_KEY)
    {
     // Serial.println(DACnum);

     
      Serial.println(DACnum);

  //output to DAC 0-4096   
    dac.setVoltage(DACnum, false);


    digitalWrite(LED,HIGH);  //Turn LED on
    digitalWrite(GATE,HIGH);  //Turn GATE on
  
     }
     else{
      digitalWrite(LED,LOW);  //Turn LED off
      digitalWrite(GATE,LOW);  //Turn GATE off
      
     }

      

      }

Make an array of size 49 to hold the pitch values. The keyboard number -1 (0-48) is the index into the array. Choose an array type of sufficient size to hold the pitch values - 0 to 255 = uint8_t, 256 to 16384 = unsigned int.

Also, insure your array index doesn't go out of bounds, like trying to access non-existent element [52]. Bad things will happen.

This sounds awfully like the problem in your other thread

See Converting matrix key input to midi note numbers - Programming Questions - Arduino Forum

Ok it seems my real question was how do i store values higher than 256 in an array and i think this answers it - il look into it thanks