I wasn’t sure whether I should make another thread, but thought it best not to as it was on the same subject of converting a Yamaha B35-N organ into a MIDI interface, just minus the shift registers as i’ve been advised by vets over on Organ Forum to do away with them and make my life easier lmao. If I’ve broken any multipost rules please merge my posts and I’ll try and keep it cleaner
I’ve resolved the ‘?’ issues in Serial Monitor with debugging code from the board and am now able to get useful debug output from the mega, I’d left some tweaks behind from another project.
Kevin, thank you once again for your very insightful blog. I’ve been trying to use your code with slight modification for a 4x12. I wired up my circuit making tweaks to your schematic and code to accomodate for the Arduino Mega, and after uploading the code and inserting another Serial.println for debugging to show when the board is ready I was unable to get any midi messages from the keyboard. I know for sure the problem isn’t your code, but there’s always the possibility that in my naivety trying to make 4x12 work I’ve broken something that end. I’d be incredibly grateful if you could look over this code and tell me if I’ve done silly things to it, haha.
Code
/*
// Simple DIY Electronic Music Projects
// diyelectromusic.wordpress.com
//
// Keyboard MIDI Matrix Decode
// https://diyelectromusic.wordpress.com/2020/09/22/keyboard-midi-matrix-decode/
//
MIT License
Copyright (c) 2020 diyelectromusic (Kevin)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
Using principles from the following Arduino tutorials:
Arduino MIDI Library - https://github.com/FortySevenEffects/arduino_midi_library
Keypad Tutorial - https://playground.arduino.cc/Main/KeypadTutorial/
*/
#include <MIDI.h>
#include <Keypad.h>
// This is required to set up the MIDI library.
// The default MIDI setup uses the Arduino built-in serial port
// which is pin 1 for transmitting on the Arduino Mega.
MIDI_CREATE_DEFAULT_INSTANCE();
// Set up the MIDI channel to send on
#define MIDI_CHANNEL 1
#define MIDI_LED LED_BUILTIN
const byte ROWS = 4;
const byte COLS = 12;
char keys[ROWS][COLS] = {
{29,30,31,32,33,34,35,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}
};
byte rowPins[ROWS] = {22,24,26,28}; //connect to the row pinouts of the keyboard
byte colPins[COLS] = {30,31,32,33,34,35,36,37,38,39,40,41}; //connect to the column pinouts of the keyboard
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
MIDI.begin(MIDI_CHANNEL_OFF);
Serial.begin(9600);
pinMode(MIDI_LED, OUTPUT);
Serial.println("Arduino is ready");
}
void loop() {
// Fills kpd.key[ ] array from Keypad library with up-to 10 active keys.
// Returns true if there are ANY active keys.
if (kpd.getKeys())
{
for (int i=0; i<LIST_MAX; i++) // Scan the whole key list.
{
if ( kpd.key[i].stateChanged ) // Only find keys that have changed state.
{
switch (kpd.key[i].kstate) {
case PRESSED:
digitalWrite(MIDI_LED, HIGH);
Serial.print(kpd.key[i].kchar,DEC);
Serial.println(" Pressed");
MIDI.sendNoteOn(kpd.key[i].kchar, 127, MIDI_CHANNEL); // Engage MIDI note for pressed keys
break;
case HOLD:
break;
case RELEASED:
MIDI.sendNoteOff(kpd.key[i].kchar, 0, MIDI_CHANNEL); // Disengage MIDI note for released keys
digitalWrite(MIDI_LED, LOW);
break;
case IDLE:
break;
}
}
}
}
} // End loop
If not, this leads to my potential primary issue and if anyone can help to point me into the right direction on how to make this work I’d be indebted.
Over on my Organ Forum thread, it’d been identified that I likely have phosphor bronze contacts which from what I’ve been told would require 12v and protection for the arduino in order to be able to use those as inputs. Can anyone give me a second opinion on this? Just to see a MIDI message out of this thing, even if utterly useless, jumpy and scratchy would be a much needed victory. I’ve updated the initial Google Drive link with photographs of the contact switches. Ignore the pictures of the 12v PSU, I’ll likely use a wall wart with lower ampage unless I find myself needing to drive anything thirsty
Thank you all once again for any help and direction you may be able to provide