So, today i had some time off so i came back to the Xilophone project.
i am now working on having the buttons working.
The idea is to have 4 button assignable to any button,sample,..., in the music software, like for instance play, rec, trigger a sample, start an FX, mute, solo...
i have the button plugged to the arduino in pins 8,9,10, and 11 and i am using the internal pull up resistors.
this is the code i am using is this:
int button1Pin = 8;
int button2Pin = 9;
int button3Pin = 10;
int button4Pin = 11;
void setup() {
pinMode(8, INPUT); //Input pin for Button 1 in Breadboard
digitalWrite(8, HIGH); // Activates internal resistor in Pin 8
pinMode(9, INPUT); //Input pin for Button 2 in Breadboard
digitalWrite(9, HIGH); // Activates internal resistor in Pin 8
pinMode(10, INPUT); //Input pin for Button 3 in Breadboard
digitalWrite(10, HIGH); // Activates internal resistor in Pin 10
pinMode(11, INPUT); //Input pin for Button 4 in Breadboard
digitalWrite(11, HIGH); // Activates internal resistor in Pin 10
}
void loop() {
// BUTTON 1 (Connected to pin 8, CC channel 80)
if(digitalRead(

= LOW){
MIDI_TX(0xB0, 80, 127);
}
// BUTTON 2 (Connected to pin 9, CC channel 81)
if(digitalRead(9) = LOW){
MIDI_TX(0xB0, 81, 127);
}
// BUTTON 3 (Connected to pin 10, CC channel 82)
if(digitalRead(10) = LOW){
MIDI_TX(0xB0, 82, 127);
}
// BUTTON 4 (Connected to pin 11, CC channel 83)
if(digitalRead(11) = LOW){
MIDI_TX(0xB0, 82, 127);
}
}
and the MIDI_TX that i am using for the whole code is:
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
status = MESSAGE + midichannel;
Serial.write(status);
Serial.write(PITCH);
Serial.write(VELOCITY);
}
Today i plugged everything in.
The piezo disks are working fine! =)
The buttons are working but there is one problem. Each time i press a button it send a message CONTINUOUSLY without stopping.
How could i change it so it will send a message when i push it down, and then wait and send again another message ONLY when i press the button again?
I have tried a couple of times to write something using a "buttonState" var, but i didn't manage to make it work.
Any ideas or pointers in the right direction?
Thanks