Aruduino Mega MIDI controller

Hi guys.
I am totally new to Arduino, but have so much fun with it (to a point:)).
For now, I am trying to build a controller that will convert my old church analog organ into MIDI console.

Using some examples, and common logic, i got something like below. However ... ther must be mistake somewhere, since my Serial console outputs:

14:19:00.944 -> 128 - 41 pressed
14:19:00.944 -> 128 - 91 pressed
14:19:00.944 -> 128 - 97 pressed
14:19:00.944 -> 128 - 41 pressed
14:19:00.978 -> 128 - 91 pressed
14:19:00.978 -> 128 - 97 pressed
14:19:00.978 -> 128 - 41 pressed
14:19:00.978 -> 128 - 91 pressed
14:19:00.978 -> 128 - 97 pressed
14:19:00.978 -> 128 - 41 pressed
14:19:00.978 -> 128 - 91 pressed
14:19:00.978 -> 128 - 97 pressed
14:19:00.978 -> 128 - 41 pressed

I am surprised to see that, as it appears to happen only for couple PIN's. Moreover, there are no electronic connections made yet, so empty, unwired pins. Another mistery ... 128 message should be sent when key was released, but there's no 144 message stating it was ever pressed ...

Since I am new and not allowed to upload attachments - code here: Nov 22 7:00 AM - Codeshare

Surprising bit is that, if i modify my function so it looks:

void checkColumnsForRow(int row) {
    manual1[row][0] = digitalRead(A8);
    manual1[row][1] = digitalRead(A9);
    manual1[row][2] = digitalRead(A10);
    manual1[row][3] = digitalRead(A11);
    manual1[row][4] = digitalRead(A12);
    manual1[row][5] = digitalRead(A13);
    manual1[row][6] = digitalRead(A14);
    manual1[row][7] = digitalRead(A15);
    Serial.print(row); Serial.print(": ");
    Serial.print(manual1[row][0]); Serial.print(", ");
    Serial.print(manual1[row][1]); Serial.print(", ");
    Serial.print(manual1[row][2]); Serial.print(", ");
    Serial.print(manual1[row][3]); Serial.print(", ");
    Serial.print(manual1[row][4]); Serial.print(", ");
    Serial.print(manual1[row][5]); Serial.print(", ");
    Serial.print(manual1[row][6]); Serial.print(", ");
    Serial.print(manual1[row][7]); Serial.print(", ");
    Serial.println("");
}

It can output this way:

0: 1, 1, 1, 1, 1, 1, 1, 1, 
1: 1, 1, 1, 1, 1, 1, 1, 1, 
2: 1, 1, 1, 1, 1, 1, 1, 1, 
3: 1, 1, 1, 1, 1, 1, 1, 1, 
4: 1, 1, 1, 1, 1, 1, 1, 1, 
5: 1, 1, 1, 1, 1, 1, 1, 1, 
6: 1, 1, 1, 1, 1, 1, 1, 3, 
7: 2, 1, 1, 1, 7, 3, 1, 1,

How is this possible, i thought digitalRead can be either 0 or 1, not 2 or 7 or 3 ...
Shortened version... Nov 14 9:42 PM - Codeshare

byte manual1[7][7];

    Serial.print(manual1[row][7]); Serial.print(", ");

'7' is an invalid index for an array of size [7][7]

And don't use 'magic numbers' in your sketch. E.g. define a meaningful name for every pin, and use only that name in your sketch. Otherwise it is nearly not maintainable. And even pins can be arranged in an array ...

To be honest - the complexity of your project obviously goes beyond your actual knowledge of the c++ language. I don't want to spoil your fun with the Arduino - on the contrary. But start with smaller projects to acquire the knowledge. Anything else will only end in frustration.
First thing to learn should be the for loop.

I doubt someone will investigate your copy/paste monster to find errors.
I doubt you ever will get this sketch running.

Thanks for your "input".
As some say ... Do nothing and get nothing...

I wouldn't even learn CPP in first place if not the analog organ I want to change to midi due to some electronic failures.

Surprisingly when I changed byte to int it works. I know code is massive but until I get my PCBs from JLCPCB I just play around, and my sketch is based on one of Arduino projects out there.

I didn't say you should do nothing - but step by step.

If you still want to go with try and error ... you will never reach the knowledge. int instead of byte is definitely not the solution. I told you what the problem is.

Really? Which one?

This one

Yeah, you can find a lot of really bad programming examples out there in the internet. But if you think that's the right thing for you, stick with it.
I'm out here then. Good luck!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.