MIDI kontroler wip (arduino uno)

main
Jurij Podgoršek 2022-09-20 21:00:13 +02:00
parent 1f55fe5df8
commit a332223248
1 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,73 @@
#include <OSCBundle.h>
// SERIAL
#ifdef BOARD_HAS_USB_SERIAL
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
#else
#include <SLIPEncodedSerial.h>
SLIPEncodedSerial SLIPSerial(Serial); // Change to Serial1 or Serial2 etc. for boards with multiple serial ports that dont have Serial
#endif
OSCBundle bundle;
byte knofi[] = {
2, // gor (clip)
3, // dol (clip)
4, // levo (track)
5, // desno (track)
6, // quantize
7, // duplicate
8, // delete
9, // play/pavza
10,// overdub on/off
11,// record arm on/off
12,// record 4 beats
13,// record 8 beats
14 // record on/off
};
byte KNOFI_LEN = 13;
// Za stanje vrednosti
byte knofi_prej[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const char* kanali[15] = {
"/premakni/gor",
"/premakni/dol",
"/premakni/levo",
"/premakni/desno"
};
void setup() {
for(int i = 0; i < KNOFI_LEN; i++) {
pinMode(knofi[i], INPUT_PULLUP);
}
//Serial.begin(9600);
SLIPSerial.begin(115200);
}
byte vrednost;
void loop() {
//Serial.println("Keys pressed:");
for(int i = 0; i < KNOFI_LEN; i++) {
vrednost = !digitalRead(knofi[i]);
//Serial.print(vrednost);
//Serial.print(", ");
// Je gumb sveze vklopljen?
if (!knofi_prej[i] && vrednost) {
bundle.add(kanali[i]);
//Serial.println(kanali[i]);
}
knofi_prej[i] = vrednost;
}
//Serial.println("");
SLIPSerial.beginPacket();
bundle.send(SLIPSerial);
SLIPSerial.endPacket();
//Serial.println("");
bundle.empty();
}