Skip to content

Commit

Permalink
store MIDI CC numbers in buttons array directly
Browse files Browse the repository at this point in the history
also:
* change some var types to uint8_t instead of int
* add "ready" log messages (also displayed in less verbose mode)
  • Loading branch information
JOJ0 committed Nov 15, 2018
1 parent 649d310 commit 3b36122
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions matrixmidi.ino
Expand Up @@ -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 outPins[] = {6,7,8}; // the rows
const uint8_t inPins[] = {9,10,11,12}; // the columns const uint8_t inPins[] = {9,10,11,12}; // the columns
const uint8_t buttons[][3] = { uint8_t buttons[4][3] = {
{'1','2','3'}, {101,102,103},
{'4','5','6'}, {104,105,106},
{'7','8','9'}, {107,108,109},
{'*','0','#'}, {110,111,112},
}; };


void setup() void setup()
Expand All @@ -34,25 +34,27 @@ void setup()
aSerial.setPrinter(USBserial); aSerial.setPrinter(USBserial);
aSerial.setFilter(VERBOSITY); aSerial.setFilter(VERBOSITY);
aSerial.DEBUGGING; // enable/disable debug output in #define section 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() void loop()
{ {
for (int col = 0; col < sizeof(outPins); col++) for (uint8_t col = 0; col < sizeof(outPins); col++)
{ {
digitalWrite(outPins[col], HIGH); 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) if (digitalRead(inPins[row]) == HIGH) // blink led if inPin is HIGH)
{ {
digitalWrite(ledPin, HIGH); digitalWrite(ledPin, HIGH);
aSerial.vvv().p("yes, it's high: ").p(col).p(" ").pln(row); aSerial.vvv().p("yes, it's high: ").p(col).p(" ").pln(row);
aSerial.vvv().p("button CC: ").pln(buttons[row][col]);
aSerial.vvv().pln(); aSerial.vvv().pln();
} }
} }
digitalWrite(outPins[col], LOW); 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); digitalWrite(ledPin, LOW);
} }

0 comments on commit 3b36122

Please sign in to comment.