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