Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

keyboardscanner

> 编程语言
Open source

Turn your broken (or unused) keyboard into a MIDI controller (with velocity, sustain pedal, pitch bend, mod wheel)

99 stars0 likes1 views
WebsiteGitHub

About

Turn your broken (or unused) keyboard into a MIDI controller (with velocity, sustain pedal, pitch bend, mod wheel)

Moura's Keyboard Scanner

Turn your broken (or unused) keyboard into a MIDI controller

This Arduino sketch was the one that I used to make the project demonstrated in this video. It is about a keyboard controller that I've made using an old Alesis QS6 Keyboard directly connected to an Arduino Mega rev3 acting as keyboard scanner with velocity reading and sustain pedal support.

In 2017 I did the same with another keyboard (an old Casio from a friend). The code was refactored and a great library called DIO2 was used to speed up the scanning and clean up the old code.

In 2020, thanks to Leandro Meucchi, from Argentina, the code improved to be used with any keyboard. He made the PDF showing the keyboard wiring for Yamaha PSR530 keyboard, that helps a lot to understand what needs to be done.

In 2025 Emerson Seiler did a great job adding Kurzweil SP76II configuration + schematics, velocity sensitivity curves and potentiometers support, as he shows here. He also suggested to explode the code into small pieces.

I started 2026 working on Emerson Seiler's job as an opportunity to do a refactoring, creating the concept of "models" and merging his code into the main line. I also experimented mapping the rows x cols in a most professional way (matching the cols to Arduino Mega PORTs) to observe the gain in scans per second (Hz). It is about 7 times. I've got a stable 7KHz using my M-Audio Keystation 88 II keybed.

In 2026, Emerson Seiler implemented an i2c screen system with an encoder for controlling mappable MIDI buttons and potentiometers, see ui_ modules.

Features

  • Sustain pedal
  • Velocity sensitivity with curves support
  • Potentiometers
  • Assignable buttons and potentiometers with real-time MIDI command editing via rotary encoder and I2C display

How velocity works

Normally it is a ribbon rubber with two contacts for each key that touch the board in two diffent moments: since the key was pressed until it slopes the board completly. The code measure the difference, varying between 2 and 20 ms (useful range), depending on the keyboard. It is transformed into a MIDI value from 0 to 127.

Diagram of one rubber key

This scheme makes clear how to identify input and output pins. This has been the main question of guys on Youtube. I hope it helps:

How to make your own MIDI controller

  1. Disassemble the keyboard to have access to the flat cables (one, two or even three, depending on the number of keys and manufacturer);
  2. Using a multimeter with the diode testing function selected, find out and understand the matrix, starting from the first key. Some keyboards have a logical pattern, some doesn't;
  3. Connect the ribbon pins directly to the Arduino Mega (because it has enough pins to connect any keyboard with velocity). You dont't need to change anything in the keyboard circuit board;
  4. Duplicate one of the existing models and change the pins in the model.h (output_pins + input_pins), uncomment DEBUG_MIDI_MESSAGE in midi.cpp and see the console output;
  5. If the MIDI messages looks good, comment DEBUG_MIDI_MESSAGE back and use some SerialMIDI Bridge (I use serialmidi on macOS) to test the keyboard with some softsynth to make sure that everything goes well;
  6. Optionally, consider turning your Arduino into a MIDI device using HIDUINO, mocoLUFA or other similar firmware.
  7. Enjoy!

Assignable buttons and potentiometers

To enable this feature:

  1. Install libraries Adafruit GFX and Adafruit SSD1306 by Adafruit
  2. Enable the EXTENSION (UI) module in extensions.h
  3. For buttons, define the quantity in BUTTONS_ASSIGN_NUMBER and the pins in MIDI_BUTTONS_PINS in ui.h
  4. For potentiometers, define the quantity in POTS_ASSIGN_NUMBER and the pins in MIDI_POTS_ANALOG_PINS in ui.h
  5. The wiring diagrams for the display, encoder, buttons, and potentiometers are available in ui.h

Converting an Arduino Mega into a MIDI device

To accomplish this we need to overwrite Arduino Mega's firmware with one that boots up as a regular MIDI (and allows us switch the boot mode to the default Arduino USB/serial, when needed). We just need to:

  • Make sure that SERIAL_SPEED is set to 31250 in the code;
  • Download dualMoco.hex firmware from here;
  • Write the firmware using this procedure;
  • Now the device should be recognized as a regular MIDI device.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++arduinoarduino-megaarduino-mega2560-boardkeyboard

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言