-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_change_e_bank_select.ino
44 lines (40 loc) · 1.24 KB
/
program_change_e_bank_select.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*IMPLEMENTAÇÃO MIDI DE MUDANÇA PROGRAM\VOICE\PRESET E SELEÇÃO DE BANCO MAIS REPRESENTATIVO
ROBERTO GOMES 31/01/2020
*/
byte program = 0;
byte msb = 0; //CC MSB Bank Select
#define cc 32 // 32 or 0
#define prox 2 //digital pin arduino(preset +)
#define ante 3 //digital pin arduino(preset -)
#define prox_bank 4 //digital pin arduino(bank +)
#define ante_bank 5 //digital pin arduino(bank -)
void setup() {
Serial.begin(115200);
pinMode(prox, INPUT_PULLUP);
pinMode(ante, INPUT_PULLUP);
pinMode(prox_bank, INPUT_PULLUP);
pinMode(ante_bank, INPUT_PULLUP);
}
void loop() {
if (digitalRead(prox) == LOW && program < 127) {
program++; program_change(0xc0, program); delay(200);
}
if (digitalRead(ante) == LOW && program > 0) {
program--; program_change(0xc0, program); delay(200);
}
if (digitalRead(prox_bank ) == LOW && msb < 127) {
msb++; control_change(0xb0, cc, msb); delay(200);
}
if (digitalRead(ante_bank ) == LOW && msb > 0) {
msb--; control_change(0xb0, cc, msb); delay(200);
}
}
void program_change(byte Status, byte Data) {
Serial.write(Status);
Serial.write(Data);
}
void control_change(byte cc_Status, byte Command, byte Value) {
Serial.write(cc_Status);
Serial.write(Command);
Serial.write(Value);
}