A simple portable USB MIDI controller based on Raspberry-PI Pico and a 16-button keypad, written in Circuit Python

Overview

RPI-Pico-16-BTn-MIDI-Controller-using-CircuitPython

A simple portable USB MIDI controller based on Raspberry-PI Pico, written in Circuit Python.

Links/ References:

YouTube Link for My Demo: 
CircuitPython UF2 file Download: https://circuitpython.org/board/raspberry_pi_pico/
CircuitPython Library Download: https://circuitpython.org/libraries
CircuitPython Docs on the modules used: https://circuitpython.readthedocs.io/en/latest/shared-bindings/displayio/index.html
Mu Editor Download Link: https://codewith.mu/

*** Please make sure to match the library and the UF2 file versions ***
*** Even Notepad can be used to modify the "code.py" file on the RPI-Pico, but Mu editor has the Serial-terminal integrated and also checks for syntax and other issues in the code, hence I used the above. ***
*** Only issue with (the version of Mu) editor I have is that it crashes if large amoumnt of serial data needs to be displayed and/or the data is updated too fast in the serial terminal. ***

Detailed Description of the project/ device:

The aim is to create a simple and portable USB MIDI controller to be used with DAWs availble on mobile devices, e.g., FL Studio Mobile, Garage Band, etc. 
This is because I personally find playing something on a touch-screen to be very difficult, hence if I have any spontaneous musical ideas, I almost always have to sit down with my laptop, plug the usb-audio-interface, plug my keyboard as MIDI device, etc etc, which sometimes may or may not be possible depending on the situation, as well as mood.
*** I am fully aware that portable MIDI controllers and Keyboards are readily available, but where's the fun in just simply buying them, when you can make one yourself ;-) ***
*** If one is interested solely in the music-production aspect, I will suggest to get the commercially available devices and ignore this project, as it will save precious time, but if you like to DIY, then please keep reading ***

The device (after construction) shows up and acts as general MIDI device in PC or Android. I have tested in Windows 10 with Waveform-11 and in Android Smartphone with FL-Studio mobile, and it works with both and device is recognized without any drivers. Thanks to the amazing libraries from Adafruit Industries.

The controller is USB bus powered and has 16-buttons in the keypad, which can be used to send MIDI notes. Multiple notes can be sent at ones, but the polyphony is limited by the ghost-note effect of the 4x4 button matrix. This can be fixed by using diodes with switches, one can google for "diode keypad matrix" regarding the same for more information.

The controller's GUI consists of the 128x64 oled screen and the rotary encoder. The notes for each key in the keypad is displayed and with the rotary encoder the velocity value can be selected, as well as transpose and octave. 

The controller also has a scale mode, where currently 10 scales can be selected, with chromatic-scale as the default.
It also has a chord mode, where Power, Major, Minor and Diminshed chords can be sent by presseing only one button.

For more information and a demo of the features, please visit the YouTube link.

Parts Required (excluding the PC, MIDI-host-device and the usb-cable):

1. Raspberry-Pi Pico microcontroller - 1pc
2. 0.96 inch 128x64 monochrome oled display (here the blue one is used, as it is cheaper). - 1pc
3. Rotary encoder with switch (5-pins, 2-pins for built-in switch and 3 pins for the encoder) - 1pc
4. Prototyping PCB (Vero-board) or breadboard, for connecting everything together - 1pc
5. 1 Mega Ohm resistor as pull-down for the touch-input - 1pc
6. Some Connecting wires - as per requirement

Hardware Connection Information:

1. Currrent Keypad Setup:

Keypad Pins:      a   b   c   d   e   f   g   h   i   j   k 
RPI Pico Pins:    GP0 GP1 GP2 GP3 GP4 GP5 GP6 GP7 GP8 GP9 GP10

Matrix:             1(c,b)   2(c,d)   3(c,e)   4(h,i)
                    5(a,b)   6(a,d)   7(a,e)   8(g,i)
                    9(f,k)   10(f,d)  11(f,e)  12(f,i)
                    13(j,k)  14(j,d)  15(j,e)  16(j,i)
                    Encoder-Switch (h,k)

2. Encoder Connection:

                    L to R, knob facing towards viewer:
                    clk (pin-1): GP14 and dt (pin-3): GP15, com (pin-2): Gnd

3. I2C 0.96 Blue OLED Connections:

                    sda-pin: GP20 and scl-pin: GP21; 
                    vdd, vss to 3.3V and gnd respectively 
                    Address: 0x3C

4. Touch Input for Sustain:

                    GP11 pin, and a 1meg resistor pull-down from the pin to gnd.

Notes:

1. The keypad I have used here is non-standard. I found and bought the same from my local electronic shop, and it is most likely a replacement part for land-line telephone. But the code in the "scanKBD()" function, can be easily modified to accomodate the readily available 4x4 matrix keypads.

2. Based on the above, since I had some extra lines available for the 16-key matrix, I placed the encoder switch between h,k nodes, if standard 16-key, i.e., 4x4 matrix is used, the encoder pin can be shifted to any other GPIO pin. The encoder switch-reading is done inside the main while loop. 

3. The oled brightness is currently set to 0.4 (i.e., 40%), and the same can be changed in the "Initializing the 0.96inch OLED Display" portion of the code.

4. The threshold for the touch-input (for sustain) can be set in the "Setting Touch-pin for Sustain Input" portion of the code.

5. If the oled screen has different address (or different I2C speed, here 1,000,000 is used), the same can also be modified in the "Initializing the 0.96inch OLED Display" section.

Steps to load the code in RPI-Pico, (many other tutorials are also available on the internet on how to load CircuitPython in RPI-Pico, please feel free to refer to them):

1. For a new/ fresh RPI-Pico which is not setup for circuit python, press and hold the "bootsel" button on the Pico, and then plugin to the PC and release the button.

2. The Pico should show-up as a drive "RPI-RP2", and in that drive copy the the CircuitPython's UF2 file, either from this repository or from the CircuitPython page, link mentioned above, near the heading.

3. After the UF2 file is copied, the Pico now appears as a new drive ("CIRCUITPY") and it should contain the "lib" folder and the "code.py" file.

4. In the lib-folder all the required libraries for code.py should be present, and one can copy the contents of the lib-folder attached in this repository or download the corresponding latest versions from the CircuitPython page. 

*** Please make sure, the UF2 file and the libs used are of the same version, otherwise errors may occur ***.

5. In the Pico's "code.py" file, copy the contents of the "16-BTn_MIDI_Controller_ver1.py" file present in this repository, and as soon as the changes are saved in the "code.py" file, the code should start running.

6. Please make the required changes to the "code.py" file to match the hardware connections in your design.
Owner
Rounak Dutta
Rounak Dutta
Modi2-firmware-updater - MODI+ Firmware Updater With Python

MODI+ Firmware Updater 실행 준비 python3(파이썬3.9 혹은 그 이상의 버전)를 컴퓨터에 설치 python3 -m pip

LUXROBO 1 Feb 04, 2022
智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件

Drone智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件。它以A、B两国在C区开展无人机战争为背景,该系统的核心功能是通过仿真平台规划无人机航线,并进行验证输出,数据可导入真实无人机,使其按照规定路线精准抵达战场任一位置,支持多人多设备编队联合行动。

wwy 349 Jan 03, 2023
Raspberry Pi Power Button - Wake/Power Off/Restart(Double Press)

Control Raspberry pi with physically attached button. Wake, Power Off, and Restart (Double Press) . Python3 script runs as a service with easy installation.

Stas Yakobov 16 Oct 22, 2022
This Home Assistant custom component adds support for controlling Midea dehumidiferes on local network.

This is a custom component for Home assistant that adds support for Midea dehumidifier appliances via the local area network. midea-dehumidifier-lan H

Nenad Bogojevic 97 Jan 08, 2023
Software framework to enable agile robotic assembly applications.

ConnTact Software framework to enable agile robotic assembly applications. (Connect + Tactile) Overview Installation Development of framework was done

Southwest Research Institute Robotics 29 Dec 01, 2022
This is an incredible led matrix simulation using the ultimate mosaik co-simulation framework.

This project uses the mosaik co-simulation framework, developed by the brilliant developers at the high-ranked Offis institue for computer science, Oldenburg, Germany, to simulate multidimensional LE

Felix 1 Jan 28, 2022
Ingeniamotion is a library that works over ingenialink and aims to simplify the interaction with Ingenia's drives.

Ingeniamotion Ingeniamotion is a library that works over ingenialink and aims to simplify the interaction with Ingenia's drives. Requirements Python 3

Ingenia Motion Control 7 Dec 15, 2022
circuitpython version of PyBasic for microcontrollers

cPyBasic Circuitpython version of PyBasic for microcontrollers Current version work only for Adafruit titano & CardKB for now. The origninal PyBasic w

BeBoXoS 3 Nov 14, 2021
Python application, displaying currently played track from Spotify on OLED display connected via I2C

RaspberryPi Spotify OLED Display This application will display currently played track on SSD1306 OLED display connected to RaspberryPi. Displayed stuf

Wojciech Olech 2 Dec 30, 2021
It is a program that displays the current temperature of the GPU and CPU in real time and stores the temperature history.

HWLogger It is a program that displays the current temperature of the GPU and CPU in real time and stores the temperature history. Sample Usage Run HW

Xeros 0 Apr 05, 2022
🏡 My Home Assistant Configs. Be sure to 🌟 my repo to follow the updates!

Home Assistant Configuration Here's my Home Assistant configuration. I have installed HA on a Lenovo ThinkCentre M93P Tiny with an Intel Dual-Core i5-

iLyas Bakouch 25 Dec 30, 2022
This allows you to record keyboard and mouse input, and play it back using pynput.

Record and Play with Python! This allows you to record keyboard and mouse input, and play it back (with looping) using pynput. It allows for automatio

George Jensen 45 Jan 02, 2023
SALUS THERMOSTAT Custom component for Home-Assistant

Home-Assistant Custom Components Custom Components for Home-Assistant (http://www.home-assistant.io) Salus Thermostat Climate Component My device is R

21 Dec 18, 2022
FHEM Connector for FHT Heating devices

home-assistant-fht from: https://github.com/Rsclub22 FHEM Connector for FHT Heating devices (connected via FHEM) Requires FHEM to work You can find FH

5 Dec 01, 2022
A refreshed Python toolbox for building complex digital hardware

A refreshed Python toolbox for building complex digital hardware

nMigen 1k Jan 05, 2023
Activate Numpad inside the touchpad with top right corner switch or F8 key

This is a python service which enables switching between numpad and touchpad for the Asus UX433. It may work for other models.

Mohamed Badaoui 230 Jan 08, 2023
Christmasvillage-rpi - Raspberry Pi relay controller for ChristmasVillage.io

ChristmasVillage.io Relay Controller Links ChristmasVillage.io - Live Stream & Controls Youtube Instagram About This repository controls the light rel

Grant Windes 2 Feb 15, 2022
A Raspberry Pi Pico powered Macro board, like a Streamdeck but cheaper and simpler.

Env-MCRO A Raspberry Pi Pico powered Macro board, like a Streamdeck but cheaper and simpler. (btw this image is a bit outdated, some of the silkscreen

EnviousData 68 Oct 14, 2022
Tool to create 3D printable terrain with integrated path/road part files (Single material 3d printer)

BACKGROUND This has been an ongoing project of mine for a few months now. I run trails a lot and original the goal was to create a function to combine

9 Apr 26, 2022
ESP32 micropython implementation of Art-Net client

E_uArtnet ESP32 micropython implementation of Art-Net client Instalation Use thonny Open the root folder in thonny and upload the Empire folder like i

2 Dec 07, 2021