So with thanks for erik from the pcorgan.com forum (dutch), I figured out the last bit of the code and the pedal has been working for 2 weeks now. Its awsome, especialy since I put a lot of hours into it. The code as it is now is as follows:
void setup() {
Serial.begin(31250);
for (int i = firstPin; i < firstpin + 32; i++){
pinMode(i, INPUT_PULLUP);
}
}
void loop() {
vol = analogRead(A5);
vol = map(vol, 0, 1023, 0, 127);
for (int i = 0; i < 32; i++) {
int input = digitalRead(i+firstPin);
if (inputPins != input){
if (input == LOW) {
noteOn(0x90, i + firstNote, vol);
}
else {
noteOn(0x80, i + firstNote, 0x00);
noteOn(0x80, i + firstNote, 0x00);
}
inputPins = input;
}
}
delay(50);
}
void noteOn(byte cmd, byte data1, byte data2) {
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);
delay(10);
}