Simple 4 pot 4 button midi controller advice please

Hi,
My first post. Hope it's in the correct topic..........
I've built a simple midi controller with 4 pots (working great) and 4 buttons (not working). This is my code:

//This is the 4 pot version, buttons not working yet

int v4 = 4;
int v4_ = 4;
int v3 = 3;
int v3_ = 3;
int v2 = 2;
int v2_ = 2;
int v1 = 1;
int v1_ = 1;
int threshold = 2;
int int_to_midi_ratio = 1024 / 128;
void SendMidiToSerial (unsigned char word0, unsigned char word1, unsigned char word2) {
Serial.write(word0);
Serial.write(word1);
Serial.write(word2);
}
void setup () {
Serial.begin(57600);
}
void loop () {
v4 = analogRead(4) / int_to_midi_ratio;
v3 = analogRead(3) / int_to_midi_ratio;
v2 = analogRead(2) / int_to_midi_ratio;
v1 = analogRead(1) / int_to_midi_ratio;

if (v4 - v4_ >= threshold || v4_ - v4 >= threshold) {
v4_ = v4;
SendMidiToSerial(176, 44, v4);
}
if (v3 - v3_ >= threshold || v3_ - v3 >= threshold) {
v3_ = v3;
SendMidiToSerial(176, 43, v3);
}
if (v2 - v2_ >= threshold || v2_ - v2 >= threshold) {
v2_ = v2;
SendMidiToSerial(176, 42, v2);

}
if (v1 - v1_ >= threshold || v1_ - v1 >= threshold) {
v1_ = v1;
SendMidiToSerial(176, 41, v1);
}
}

Looking for a way to get the buttons to do something, anything!!! I've tried to blend two lots of code but I get errors. Thanks in advance

Have a look at the StateChangeDetecion example code so you only do something when the button BECOMES pressed not over and over while it stays pressed. Basically change the "buttonPushCounter++;" to your SendMidiToSerial with whatever parameters you decide...I can't really help you there.

BTW most discussion of MIDI is in the Audio forum, presumably because the description includes "using MIDI". But you're fine here, no problem.

Steve

Thanks Steve, a bit more for me to try

Your duplicate post has been deleted

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.