MIDI Electronic Accordion Using Two Arduinos and I2C

by Barry K in Circuits > Arduino

869 Views, 1 Favorites, 0 Comments

MIDI Electronic Accordion Using Two Arduinos and I2C

IMG_1335.jpg
MIDIElectronicAccordion_schem.jpg
MIDIElectronicAccordion_bb.jpg

I converted my Dad's old analog electronic (as opposed to acoustic) accordion into a MIDI controller. The accordion has 41 keys on the right-hand (RH) side, 24 buttons on the left-hand (LH) side (12 for bass notes; 12 for chords), and several potentiometers that I use for various functions, such as volume. The accordion also has several toggle switches, which I use for various functions, such as layering sounds (by duplicating MIDI notes on different channels).

Since the accordion has more buttons than a single Arduino Mega could handle, I needed a way to accommodate more inputs. I could have used digital port expanders, multiplexers, or keyboard matrix, etc., but didn't want to create a circuit board for them. Instead, I used two Megas and connected them via I2C. See schematic, above. There are just 4 functional sections.

  • Power (7-12V into one of the VIN pins)
  • Potentiometers into the Analog Inputs
  • Buttons/Switches into the Digital Inputs
  • MIDI Output circuit

This Instructable is intended to only discuss how I used I2C between multiple Arduinos, to merge the LH and RH buttons and sensors. I created a separate document describing the details of the design and the build process of the MIDI Electronic Accordion, and the complete code are linked in the references section, below.

Supplies

Theory of Operation

The RH Arduino acts as a Master and repeatedly requests the LH Arduino to send its button states to the RH Arduino via the Arduino's Wire library. The LH Arduino repeatedly updates state variables indicating the LH button states. Since the accordion is not velocity sensitive, the LH sends bitmaps (i.e., bytes with bits set to 1 or 0) indicating the state of each button or switch. The RH Arduino expects a specific data format in the I2C data that is sent by the LH Arduino. This format is arbitrary, and not defined by I2C; other applications could use a different data format. The RH Arduino performs the debounce functionality for both the RH and LH buttons.

I was initially concerned that there would be a noticeable delay sending LH button statuses to the RH Arduino via I2C, but there was no noticeable delay.

The hard part of the build was making the many wires, and soldering to the keys, buttons, switches, potentiometers. I used Dupont connectors to allow easy connection/disconnection of my prototype. To make the MIDI Accordion more robust, I would solder directly to headerless Arduinos.

The Build

IMG_1375.jpg
IMG_1374.jpg
IMG_1372.jpg
IMG_1534.jpg
IMG_1122.jpg
IMG_1106.jpg
IMG_1310.jpg

Testing

Testing Barry K Vibes' MIDI Electronic Accordion 20-Feb-2021

Here is a video of my Dad testing out the MIDI Electronic Accordion.

Conclusions

Using two Arduinos avoided adding extra circuitry, or creating custom boards that were required for digital input expander designs, but I did not know whether using I2C would introduce any perceptible delays in getting data from the Left-Hand Slave Arduino. I cannot hear/feel any delay.

The LH only sends 6 bytes representing the button states of 24 bass buttons, and a number of other switches on the accordion. Other similar projects may require velocity information to be sent, increasing the number of bytes to send over I2C. It is to-be-determined whether the additional data would introduce noticeable delays.

For more details of the design, and the build process, see https://docs.google.com/document/d/1Of1_CPTcffGGDEGFjAHzh3jQeN4nuGRX4Pxc-d5xu_U/.

I'd appreciate feedback on this, or alternative designs for handling more inputs than are available for a single processor.

I hope you found this Instructable, and the referenced documentation and code, informative, and helpful.

Barry