turn my musical keyboard into a MIDI keyboard

Hello , I’m new to arduino . I have a project that consists of using my music to use in any DAW keyboard music sequencer .
Take the idea of ​​a video

but by using the code does not give me the notes in order. use a matrix of 8 x 7 , and only Use a shiftregister ( 74hc595 ) if someone could explain me that can be modified to work properly, thank you # do not use the midi output as the video I send serial data to a program that interprets ( hairles midi )

My code is

#define NUM_ROWS 7
#define NUM_COLS 8

#define NOTE_ON_CMD 0x90
#define NOTE_OFF_CMD 0x80
#define NOTE_VELOCITY 127

//MIDI baud rate
#define SERIAL_RATE 9600

// Pin Definitions

// Row input pins
const int row7Pin = 2;
const int row6Pin = 3;
const int row5Pin = 4;
const int row4Pin = 5;
const int row3Pin = 6;
const int row2Pin = 7;
const int row1Pin = 8;

// 74HC595 pins
const int dataPin = 9;
const int latchPin = 10;
const int clockPin = 11;

boolean keyPressed[NUM_ROWS][NUM_COLS];
uint8_t keyToMidiMap[NUM_ROWS][NUM_COLS];

// bitmasks for scanning columns
int bits =

void setup()
int note = 31;

for(int colCtr = 0; colCtr < NUM_COLS; ++colCtr)
for(int rowCtr = 0; rowCtr < NUM_ROWS; ++rowCtr)
keyPressed[rowCtr][colCtr] = false;
keyToMidiMap[rowCtr][colCtr] = note;

// setup pins output/input mode
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);

pinMode(row1Pin, INPUT);
pinMode(row2Pin, INPUT);
pinMode(row3Pin, INPUT);
pinMode(row4Pin, INPUT);
pinMode(row5Pin, INPUT);
pinMode(row6Pin, INPUT);
pinMode(row7Pin, INPUT);


void loop()
for (int colCtr = 0; colCtr < NUM_COLS; ++colCtr)
//scan next column

//get row values at this column
int rowValue[NUM_ROWS];
rowValue[0] = digitalRead(row1Pin);
rowValue[1] = digitalRead(row2Pin);
rowValue[2] = digitalRead(row3Pin);
rowValue[3] = digitalRead(row4Pin);
rowValue[4] = digitalRead(row5Pin);
rowValue[5] = digitalRead(row6Pin);
rowValue[6] = digitalRead(row7Pin);

// process keys pressed
for(int rowCtr=0; rowCtr<NUM_ROWS; ++rowCtr)
if(rowValue[rowCtr] != 0 && !keyPressed[rowCtr][colCtr])
keyPressed[rowCtr][colCtr] = true;

// process keys released
for(int rowCtr=0; rowCtr<NUM_ROWS; ++rowCtr)
if(rowValue[rowCtr] == 0 && keyPressed[rowCtr][colCtr])
keyPressed[rowCtr][colCtr] = false;

void scanColumn(int colNum)
digitalWrite(latchPin, LOW);

if(0 <= colNum && colNum <= 8)
shiftOut(dataPin, clockPin, MSBFIRST, B00000000); //right sr
shiftOut(dataPin, clockPin, MSBFIRST, bits[colNum]); //left sr
shiftOut(dataPin, clockPin, MSBFIRST, bits[colNum-8]); //right sr
shiftOut(dataPin, clockPin, MSBFIRST, B00000000); //left sr
digitalWrite(latchPin, HIGH);

void noteOn(int row, int col)

void noteOff(int row, int col)

Right, first things first.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

Albeit it is not too complex at present, but it may well get more so.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

Until you reply and demonstrate that you understand these points that have been made so far, there is absolutely no point working through any other problems with the code, so I will leave it at that for the present.