Forum Top Banner Ad

Collapse

Ebay Classic organs

Collapse

Announcement

Collapse
No announcement yet.

Remote keyboard using Arduino

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remote keyboard using Arduino

    Those of you who have followed my posts in the past, know that I am a great booster of the use of Arduinos for carrying out all kinds of useful functions around virtual organs or pipe organs.
    In this case, the organist asked if I could provide a remote keyboard for use with choir rehearsal. Since the organ keyboards switch 15 V, I will use the Arduino outputs to drive the Great-keyboard switches using ULN2803s or some such driver chip. The external MIDI keyboard plugs into a MIDI shield that sits on top of the Arduino. Input from the keyboard is then decoded and the 61 pins on the Arduino are then turned on or off as needed. To enable stop changes, I will reserve top B and C to operate the UP and DOWN pistons on the sequencer.
    This version handles output for channel 1 only, which is what most keyboards use. It also handles "Running Status" used by many, although not all, keyboards.
    I also wrote a special decoder for a Roland E-10 synthesizer, which I had lying around. This will give the organist a transposer and the ability to record and playback a short (~5 min) piece of music.
    It always amazes me how little code is needed to perform these simple functions.

  • #2
    Here is the code. Unfortunately, posting removes the formatting
    /*
    Arduino Decoder: by John Coenraads
    =====================================
    This sketch accepts MIDI commands on channel 1, decodes them and turns the appropriate IO pins on and off.
    Bottom C (note 36) outputs on pin 2. Total outputs = 68 (pins 2 to 69).
    If boards are daisy chained, each one can be "tuned" to a specific channel.
    **This sketch handles Running Status, where the status byte is only updated when it changes.**
    Equipment: Arduino Mega + MIDI shield
    created 2021 APR 08, modified 2021 APR 08
    */
    // Declarations====================================== ====
    int i, j, k; //Counters (old Fortran habit)
    byte noteStatusRx, noteNumberRx, noteVelocityRx, tempVar; //Receive variables
    const byte status90 = 0x90, status80 = 0x80; //Define status bytes for channel 1

    //Initialize ============================================
    void setup()
    {
    Serial.begin(31250); // Set MIDI baud rate:
    while (Serial.available() > 0) {Serial.read();} //Clear serial input buffer
    Serial1.end(); Serial2.end(); Serial3.end(); //Relieve ports 1,2,3 of serial IO duty

    //Initialize 68 pins for output.
    for (i = 2; i < 70; i++)
    {
    pinMode (i, OUTPUT);
    digitalWrite (i, LOW);
    }
    }

    //Main Loop =============================================
    void loop()
    {
    while (!Serial.available()) {} //wait for serial data, port 0
    tempVar = Serial.read ();

    if ((tempVar == status90) || (tempVar == status80))
    {noteStatusRx = tempVar;
    while (!Serial.available()) {} //wait for serial data, port 0
    noteNumberRx = Serial.read ();
    while (!Serial.available()) {} //wait for serial data, port 0
    noteVelocityRx = Serial.read ();

    if (noteVelocityRx == 0) {digitalWrite (noteNumberRx - 34, LOW);}
    else {digitalWrite (noteNumberRx - 34, HIGH);}
    }

    if (tempVar <= 0x7F) //is data byte (Running Status)
    {noteNumberRx = tempVar;
    while (!Serial.available()) {} //wait for serial data, port 0
    noteVelocityRx = Serial.read ();

    if (noteVelocityRx == 0) {digitalWrite (noteNumberRx - 34, LOW);}
    else {digitalWrite (noteNumberRx - 34, HIGH);}
    }
    }

    Comment


    • #3
      Here is a picture of the final result, tested and ready to install. The driver board is a surplus Devtronix board which uses UDN 2981 high-side drivers. This board "plays nice" with the Arduino outputs as inputs. The outputs will be piggy-backed onto one of the organ's keyboards. The UDN 2981 chips appear to be quite happy connected in a wired-OR configuration with the organ key switches. The two, blue relays connect to the outputs of top C and B and will operate the UP and DOWN pistons on the sequencer so that stop changes can be made remotely.

      Click image for larger version

Name:	OrganOnterface.JPG
Views:	107
Size:	177.3 KB
ID:	765901

      Comment

      Working...
      X