int const button[] = {2, 3, 4};
int const note[] = {36, 37, 38};
int xOuld = 0;
int x = 0;
void setup() {
Serial.begin(312500);
for(int z=0;z<3;z++){
pinMode(button[z], INPUT);}
}
void loop(){
for(int z=0;z<3;z++){
int xx = digitalRead(button[z]); //read button[0] than button[1] .....
xOld = xx; //old value = xx
delay(10); //wait 10 ms
x = digitalRead(button[z]); //x is equal to the digitalRead(button[z] so if the x is not equal to xOld before the 10ms than -->
if (x == HIGH && xOud == LOW) { //if x is pressed and before the 10 ms it was not -->
Serial.write(144); // 1001 0000 = Note On Kanal 1
Serial.write(noot[z]); //36 = Noot C2
Serial.write(127);}
if (x == LOW && xOud == HIGH) { //if x is released and before the 10 ms it was -->
Serial.write(144); // 1001 0000 = Note On Kanal 1
Serial.write(noot[z]); //Note C2
Serial.write(0);}}
delay(1);
}
so anybody any ideas how to fix the code, I just want it to read the buttons and if they are HIGH send a MIDI signal and if they are LOW write the MIDI signal low and do nothing if the button is not pressed, if anybody could tell me what is wrong or write a good verrsion the code feel free to answer,
thanks alot