Skip to content
Permalink
Browse files

store MIDI CC numbers in buttons array directly

also:
* change some var types to uint8_t instead of int
* add "ready" log messages (also displayed in less verbose mode)
  • Loading branch information...
J0J0 T
J0J0 T committed Nov 14, 2018
1 parent 649d310 commit 3b36122b84b1c1b27c1aff672218007e9224d779
Showing with 11 additions and 9 deletions.
  1. +11 −9 matrixmidi.ino
@@ -10,11 +10,11 @@ const uint8_t ledPin = 13; // LED pin on most Arduino

const uint8_t outPins[] = {6,7,8}; // the rows
const uint8_t inPins[] = {9,10,11,12}; // the columns
const uint8_t buttons[][3] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'},
uint8_t buttons[4][3] = {
{101,102,103},
{104,105,106},
{107,108,109},
{110,111,112},
};

void setup()
@@ -34,25 +34,27 @@ void setup()
aSerial.setPrinter(USBserial);
aSerial.setFilter(VERBOSITY);
aSerial.DEBUGGING; // enable/disable debug output in #define section
while(!USBserial); // wait until USBserial is accessible
aSerial.v().pln("Matrix MIDI Ctrl ready...");
}

void loop()
{
for (int col = 0; col < sizeof(outPins); col++)
for (uint8_t col = 0; col < sizeof(outPins); col++)
{
digitalWrite(outPins[col], HIGH);
for (int row = 0; row < sizeof(inPins); row++)
for (uint8_t row = 0; row < sizeof(inPins); row++)
{
if (digitalRead(inPins[row]) == HIGH) // blink led if inPin is HIGH)
{
digitalWrite(ledPin, HIGH);
aSerial.vvv().p("yes, it's high: ").p(col).p(" ").pln(row);
aSerial.vvv().p("button CC: ").pln(buttons[row][col]);
aSerial.vvv().pln();
}
}
digitalWrite(outPins[col], LOW);
aSerial.vvv().pln();
}
delay(500); // enable for slower debugging, otherwise lit led can't be seen ;-)
//delay(500); // enable for slower debugging
digitalWrite(ledPin, LOW);
}

0 comments on commit 3b36122

Please sign in to comment.
You can’t perform that action at this time.