Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
| |||||
Hand tools and fabrication machines | ||||||
![]() |
| |||||
![]() |
| |||||
Arduino as a MIDI Driver to connect the Pedal Keyboard from the Wiscount Domus Recitaive Organ to PC or any MIDI instrument.
With the help of arduino, I made an interface to the PC to check the operation of the contacts in the Pedalboard.
Code 1
C/C++The script uses the Control_Surface library from https://github.com/tttapa/Control-Surface
// Interface Midi for Pedalboard Wiscount Domus Recitative
/**
* This examples shows how to use a button matrix to read many switches.
*
* @boards AVR, AVR USB, Nano Every, Due, Nano 33, Teensy 3.x, ESP32
*
* Connections
* -----------
*
* Connect a 4 × 3 matrix of buttons with the rows to pins 2, 3, 4 and 5,
* and the columns to pins 6, 7 and 8.
*
* Pull-up resistors are not necessary, because the internal ones will be used.
*
* If you want to be able to press multiple buttons at once, add a diode
* in series with each button:
* @image html Button-matrix.png
*
* Behavior
* --------
*
* When you press one of the buttons, a note on event for the corresponding note
* is sent, when you release it, a note off event is sent.
*
* Mapping
* -------
*
* The note numbers are specified in the `addresses` array.
* Map accordingly in your DAW or DJ software.
*
* Written by Pieter P, 24/09/2017
* https://github.com/tttapa/Control-Surface
*/
#include <Control_Surface.h>
// Instantiate a MIDI over USB interface.
//USBDebugMIDI_Interface midi;
//HardwareSerialMIDI_Interface midi;// - nie działa
HardwareSerialMIDI_Interface midi = Serial;
//HardwareSerialMIDI_Interface midi = Serial;
//HairlessMIDI_Interface midi;
//USBMIDI_Interface midi;
// The note numbers corresponding to the buttons in the matrix
const AddressMatrix<4, 8> addresses = {{
{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},
}};
NoteButtonMatrix<4, 8> buttonmatrix = {
{A0, A1, A2, A3}, // row pins
{2, 3, 4, 5, 6, 7, 8, 9 }, // column pins
addresses, // address matrix
CHANNEL_1, // channel and cable number
};
void setup() {
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}
Alternativ code 2
C/C++The script uses the MIDI_Controllerl library from https://github.com/tttapa/MIDI_controller
#include <Controller.h>
/*
.
This is an example of the "ButtonMatrix" class of the MIDI_controller library.
Connect a 4 × 3 matrix of buttons with the rows to pins 2, 3, 4 and 5,
and the columns to pins 6, 7 and 8.
Pull-up resistors are not necessary, because the internal ones will be used.
If you want to be able to press multiple buttons at once, add a diode
in series with each button, as shown in the schematic on the Wiki:
https://github.com/tttapa/MIDI_controller/wiki/Hardware
The note numbers are specified in the 'addresses' array.
Map accordingly in your DAW or DJ software.
Written by tttapa, 24/09/2017
https://github.com/tttapa/MIDI_controller
*/
#include "MIDI_Controller.h" // Include the library
//USBMIDI_Interface midi; // Instantiate a MIDI Interface to use, dziala z Leonardo
//HairlessMIDI_Interface midi;
//USBDebugMIDI_Interface midiInterface(115200); // dzialające
//USBDebugMIDI_Interface(unsigned long 115200);
//StreamDebugMIDI_Interface;
//SerialDebugMIDI_Interface;
//HardwareSerialDebugMIDI_Interface(Serial,115200);
//SoftwareSerialDebugMIDI_Interfa
//HardwareMIDI_Interface midi;
const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t addresses[4][8] = { // 4 wiersze 8 kolumn the note numbers corresponding to the buttons in the matrix
{ 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 }
};
const uint8_t addresses1[2][2] = { // 4 wiersze 8 kolumn the note numbers corresponding to the buttons in the matrix
{ 36, 37},
{ 44, 45}
};
// Create a new instance of the class 'ButtonMatrix', called 'buttonmatrix', with dimensions 4 rows and 3 columns, with the rows connected to pins 2, 3, 4 and 5
// and the columns connected to pins 6, 7 and 8, that sends MIDI messages with the notes specified in 'addresses' on MIDI channel 1, with velocity 127
ButtonMatrix<4, 8> buttonmatrix( {A0, A1, A2, A3}, {2, 3, 4, 5, 6, 7, 8, 9}, addresses, 1, velocity);
ButtonMatrix<2, 2> buttonmatrix1( {A4, A5}, {11,12}, addresses1, 3, velocity);
void setup() {}
void loop() {
// Refresh the buttons (check whether the states have changed since last time, if so, send it over MIDI)
MIDI_Controller.refresh();
}
/* Script for handling MIDI
* pedalboard from the Wiscount Domus Recitative organs.
* Reads a contact matrix (8 columns x 4 lines) with diodes
* and sends MIDI messages.
* Flashing LED (pin 13) every second means
* that the program is working correctly.
* The LED lights up and goes out
* while sending a MIDI message.
*
* Tested on Arduino Uno and Nano
* author: Romuald Milewski
*/
//---------------------------------------------------------------------------
//----------------------------for signalisations work:----------------------
// Variables will chang
int ledState = LOW; // ledState used to set the LED
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated
// constants won't change:
const long interval = 1000;
//-------------------------------------------------------
// define adress rovs
#define pin_adress0 A0
#define pin_adress1 A1
#define pin_adress2 A2
#define pin_adress3 A3
#define LiczbaKlawiszy (61)
boolean Key[LiczbaKlawiszy];
boolean Key_last[LiczbaKlawiszy];
int pin_data[] = {2,3,4,5,6,7,8,9}; // define data pins
int vol = 90; // walue velocity
// setup channel MIDI
//You can change the channel from 1 to 16.
int channel_on = 0x90; // kanal 1 - initial variables for midi channel
int channel_off = 0x80; // kanal 1 - initial variables for midi channel
// int channel_on = 0x91; // kanal 2
// int channel_off = 0x81; // kanal 2
// int channel_on = 0x92; // kanal 3
// int channel_off = 0x81; // kanal 3
//int channel_on = 0x93; // kanal 4
//int channel_off = 0x83; // kanal 4
// int channel_on = 0x94; // kanal 5
// int channel_off = 0x84; // kanal 5
// int channel_on = 0x95; // kanal 6
// int channel_off = 0x85; // kanal 6
// int channel_on = 0x96; // kanal 7
// int channel_off = 0x86; // kanal 7
// int channel_on = 0x97; // kanal 8
// int channel_off = 0x87; // kanal 8
void setup() {
Serial.begin (31250); // setup serial for MIDI
//Serial.begin (115200); //You can change the transmission speed if you connect Arduino to PC via Hairless Midi - serial bridge
for (int i = 0; i <= LiczbaKlawiszy -1; i++) {
Key[i] = 1;
}
// define input pin_data
for (int i = 0; i <= 7; i++) {
pinMode(pin_data[i], INPUT_PULLUP);
}
//define output pin_adress
pinMode(pin_adress0, OUTPUT);
digitalWrite(pin_adress0, HIGH);
pinMode(pin_adress1, OUTPUT);
digitalWrite(pin_adress1, HIGH);
pinMode(pin_adress2, OUTPUT);
digitalWrite(pin_adress2, HIGH);
pinMode(pin_adress3, OUTPUT);
digitalWrite(pin_adress3, HIGH);
// define output LED
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(pin_adress0, LOW);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, HIGH); // read 1-st (first) octet
digitalWrite(pin_adress3, HIGH);
for (int i = 0; i <= 7; i++) {
Key[i+0*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, LOW);
digitalWrite(pin_adress2, HIGH); // read 2-st (second) octet
digitalWrite(pin_adress3, HIGH);
for (int i = 0; i <= 7; i++) {
Key[i+1*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, LOW);
digitalWrite(pin_adress3, HIGH); // read 3-st (thrid) octet
for (int i = 0; i <= 7; i++) {
Key[i+2*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, HIGH);
digitalWrite(pin_adress3, LOW); // read 4-st (quad) octet
for (int i = 0; i <= 7; i++) {
Key[i+3*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, HIGH);
digitalWrite(pin_adress3, HIGH); // read 5-st (quad) octet
for (int i = 0; i <= 7; i++) {
Key[i+4*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, HIGH);
digitalWrite(pin_adress3, HIGH); // read 6-st (qwint) octet
for (int i = 0; i <= 7; i++) {
Key[i+5*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, HIGH);
digitalWrite(pin_adress3, HIGH); // read 7-st (sext) octet
for (int i = 0; i <= 7; i++) {
Key[i+6*8] = digitalRead(pin_data[i]);
}
digitalWrite(pin_adress0, HIGH);
digitalWrite(pin_adress1, HIGH);
digitalWrite(pin_adress2, HIGH);
digitalWrite(pin_adress3, HIGH); // read 8-st (sept) octet
for (int i = 0; i <= 7; i++) {
Key[i+7*8] = digitalRead(pin_data[i]);
}
//****************************************************
// Compare port reads and send midi messages
for (int i = 0; i <= LiczbaKlawiszy -1; i++) {
if(Key[i] != Key_last[i] ) {
if(Key[i] == 0) {
noteOn(channel_on, 36+i, vol);
}
else {
noteOn(channel_off, 36+i, 0x00);
noteOn(channel_off, 36+i, 0x00); //Double sending Midi_Off for Casio CT-670
}
}
}
//*****************************************
//*****************************************************
for (int i = 0; i <= LiczbaKlawiszy -1; i++) {
Key_last[i] = Key[i];
}
//**************************************
// Program operation signaling module
//----------------------------------------------------------
unsigned long currentMillis = millis();
// szybkość działania programu
// Serial.println(currentMillis);
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(LED_BUILTIN, ledState);
}
//---------------------------------------------------------------
}
void noteOn(byte cmd, byte data1, byte data2) {
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);
//Signaling that the MIDI message has been sent
digitalWrite(LED_BUILTIN, HIGH);
delay(20); //LED lighting time after sending the midi message from 5 to 10, max. 20 ms (and also counteracting the vibration of the contacts)
digitalWrite(LED_BUILTIN, LOW);
}



_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)





Comments