Hardware: Teensy LC, custom pcbs (one to seat Teensy, another for reed switches)
Libraries: Keypad, MIDI
Output Conundrum:
ON
6
OFF
6
ON
4
OFF
4
ON
2
OFF
2
Output generated by holding magnet close to reed switch. The switch wiring configuration is typical rows/columns.
CODE:
OUTPUT SOUGHT: What I'm really looking for are outputs according to the array figures. The numbers in the array represent MIDI note numbers. For my purposes, I only need on/off with no other MIDI info. So, the first ON in the output should present 36, the second 37, the third 38, etc...
Now, the weird thing is if I define the array as int and convert the kchar values to ints in the printlns, it reads 36, 38, 40, 42... when it should read 36, 37, 38, 39...
What am I doing wrong/missing here?!?
Libraries: Keypad, MIDI
Output Conundrum:
ON
6
OFF
6
ON
4
OFF
4
ON
2
OFF
2
Output generated by holding magnet close to reed switch. The switch wiring configuration is typical rows/columns.
CODE:
HTML:
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
#include <Keypad.h>
MIDI_CREATE_DEFAULT_INSTANCE();
const byte ROWS = 8;
const byte COLS = 8;
//Matrix begins two octaves below Middle C (C4) - MIDI note 60
char keys[ROWS][COLS] = {
{'36','37','38','39','40','41','42','43'},
{'44','45','46','47','48','49','50','51'},
{'52','53','54','55','56','57','58','59'},
{'60','61','62','63','64','65','66','67'},
{'68','69','70','71','72','73','74','75'},
{'76','77','78','79','80','81','82','83'},
{'84','85','86','87','88','89','90','91'},
{'92','93','94','95','96','97','98','99'}
};
byte rowPins[ROWS] = {1,2,3,4,5,6,7,8};
byte colPins[COLS] = {13,14,15,16,17,18,19,20};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
MIDI.begin();
}
void loop() {
if (kpd.getKeys())
{
for (int i=0; i<LIST_MAX; i++)
{
if (kpd.key[i].stateChanged)
{
switch (kpd.key[i].kstate) {
case PRESSED:
MIDI.sendNoteOn(kpd.key[i].kchar,127,1);
Serial.println(" ON ");
Serial.println(kpd.key[i].kchar);
break;
case RELEASED:
MIDI.sendNoteOff(kpd.key[i].kchar,127,1);
Serial.println(" OFF ");
Serial.println(kpd.key[i].kchar);
break;
case HOLD:
break;
case IDLE:
break;
}
}
}
}
}
OUTPUT SOUGHT: What I'm really looking for are outputs according to the array figures. The numbers in the array represent MIDI note numbers. For my purposes, I only need on/off with no other MIDI info. So, the first ON in the output should present 36, the second 37, the third 38, etc...
Now, the weird thing is if I define the array as int and convert the kchar values to ints in the printlns, it reads 36, 38, 40, 42... when it should read 36, 37, 38, 39...
What am I doing wrong/missing here?!?