Build your own MIDI circuits
Frequently Asked Questions.
MIDI & Music
MIDI and Music Information
MIDI 128 Note Keyboard Encoder


MIDI 128 Note Keyboard Encoder 


This keyboard encoder is capable of encoding any number of momentary action, push to make, single pole single throw (SPST), switches from 0 to 127 to produce the equivalent MIDI note-on/note-off data commands on any MIDI Channel (1 to 16). The encoded switches are wired via IN4148 diodes.


The unit can work with any size keyboard up to 128 notes. Any unused keys/notes can be left unconnected.


This unit can be connected to new keyboards or it can be used with an older non-MIDI keyboard by using magnetic/reed switches to isolate the old and new scanning circuits. This will allow the older keyboard synthesizer to continue to operate as normal while also providing a MIDI output.


mega_4dip_midi.jpg (221360 bytes)


MIDI 128 Note Keyboard


PRICE:  €75.00






The 128 Note Keyboard Encoder to MIDI Unit consists of:

  • The MIDI channel is selected by a 4-way DIP switch, 
  • The velocity byte is preset to a value of 100 (this can be changed on request).
  • An assembled Arduino MEGA board,
  • A 2.1mm power socket, and associated LED, 
  • USB power or external power choice,
  • A MIDI 5-pin DIN output socket,
  • The switches circuit schematic is available,



The 128 Note Keyboard Encoder to MIDI unit requires:

  • a 9v battery or equivalent DC power source
  • Suitable key-switches or magnetic reed switches and associated IN4148 diodes


Circuit Schematic:

A switches circuit schematic of the 128 MIDI keyboard encoder shows the switch connections. The circuit schematic for the Arduino MEGA is also available.







     *Click to Enlarge*

The MIDI IN and OUT connectors use  5-Pin 180 degree DIN sockets. Note that the MIDI IN/OUT wiring is polarised and the correct pins should be used.



MIDI Specification: 

 The MIDI 128 MIDI keyboard encoder can select any MIDI channel (1-16), using the 4-way DIP switch on the MIDI IN/OUT board.


DIP Switch Selections



4 3 2 1
on on on on 1
on on on off 2
on  on  off on 3
on on off off 4
on off on on 5
on off on off 6
on off off on 7
on off off off 8
off on on on 9
off on on off 10
off on  off on 11
off on off off 12
off off on on 13
off off on off 14
off off off on 15
off off off off 16

Table 1 MIDI Channel




MIDI 128 Note Keyboard Encoder Wiring:

The switches are organized in a 16 x 8 matrix (up to 128 switches) arrangement.  Note if less than 128 switches are required, then ONLY the switches required need to be wired. 

The lowest note  is switch SW0 wired via diode D0 between Pins 22 and 23 of the Arduino MEGA.

The next note  is switch SW1 wired via diode D1 between Pins 24 and 23 of the Arduino MEGA.

The next note  is switch SW2 wired via diode D2 between Pins 26 and 23 of the Arduino MEGA.

The next note  is switch SW3 wired via diode D3 between Pins 28 and 23 of the Arduino MEGA.

The next note  is switch SW4 wired via diode D4 between Pins 30 and 23 of the Arduino MEGA.

The next note  is switch SW5 wired via diode D5 between Pins 32 and 23 of the Arduino MEGA.

The next note  is switch SW6 wired via diode D6 between Pins 34 and 23 of the Arduino MEGA.

The next note  is switch SW7 wired via diode D7 between Pins 36 and 23 of the Arduino MEGA


Pin 22 is also looped to the Anodes of 15 other Diodes D8, D16, D24, D32, D40, D48, D56, D64, D72, D80, D88, D96. D104, S112,  and D120.


Pin 24 is also looped to the Anodes of Diodes D10, D19, D28, D37, D46, D55, D64, D73, D82, D91 and D100.


The other 7 pins 24,  26, 28, 30, 32, 34 and 36 are wired in a similar manner to the other Diodes.


Pin 23 is connected to switches SW0 to SW7,

Pin 25 is connected to switches SW8 to SW15,

Pin 27 is connected to switches SW16 to SW23,

Pin 29 is connected to switches SW24 to SW31,

Pin 31 is connected to switches SW32 to SW39,

Pin 33 is connected to switches SW40 to SW47,

Pin 35 is connected to switches SW48 to SW55,

Pin 37 is connected to switches SW56 to SW63,

Pin 39 is connected to switches SW64 to SW71,

Pin 41 is connected to switches SW72 to SW87,

Pin 43 is connected to switches SW88 to SW95,

Pin 45 is connected to switches SW96 to SW103,

Pin 47 is connected to switches SW104 to SW111,

Pin 51 is connected to switches SW112 to SW119,

Pin 53 is connected to switches SW120 to SW127.


Each of the other side of these group of 8 switches (eg SW0 to SW7 etc.) is wired to a diode on the Cathode (K) side (end of diode with stripe).

The other side of each of these diodes is looped to  other diodes. 


Power Supply:

The  Arduino MEGA can be powered via the USB connection or with an external power supply. The power source is selected automatically. 


External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector. A low dropout regulator provides improved energy efficiency.


The board can operate on an external supply of 7 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.