Thank you guys for answering me.
So i'm really off the course!
Let me show you exactly what i'm going to do.
This is the System exclusive message array:
The code sends this array to my MIDI gear to do some stuff.
Notes (index 8-19) are the variables which can be 0X40 or 0x0e according to state of digital inputs.
Checksum (index 20) is an another variable which depends to the value of the 12 notes and is calculated with this formula:
C + C# + D + D# + E + F + F# + G + G# + A + A# + B
Calculating the SUM, every time the result becomes bigger than 127 (0x7f), it must be subtracted from 128 (0x80)
Then we calculate the Remainder:
SUM Result % 128
and finally calculate the Checksum like this : Checksum = 128 - Remainder.
Since i'm a skinny noob, this is quite challenging for me. I have no idea how to make a FOR loop that only rolls over the indexes number 8 through 19 and not the entire array.
So far I haven't come up with any idea how to write the code to calculate the correct Checksum. So I'll appreciate your help on this issue.