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
AERO 421: Spacecraft Attitude, Dynamics, and Control Final Project.

AERO - 421 Final Project Redevelopment Spacecraft Attitude, Dynamics, and Control: Simulation to determine and control a satellite's attitude in LEO.

Gagandeep Thapar 3 Dec 16, 2022
Python library to interact with the GCE Electronics IPX800 device

A python library to control a GCE-Electronics IPX800 V4 device through its API.

Marc-Aurèle Brothier 2 Oct 20, 2021
This repository hosts the code for Stanford Pupper and Stanford Woofer, Raspberry Pi-based quadruped robots that can trot, walk, and jump.

This repository hosts the code for Stanford Pupper and Stanford Woofer, Raspberry Pi-based quadruped robots that can trot, walk, and jump.

Stanford Student Robotics 1.2k Dec 25, 2022
Control the lights of Alienware computers under GNU/Linux systems.

Before requesting support please consider that this software is not actively developed. I created it in 2014 for managing my Alienware M14X-R1 (where

rsm 111 Dec 05, 2022
🎃 Some spooky code samples to hack yourself a pumpkin 👻

🎃 Tech Or Treat 👻 It's spooky season for those who celebrate Halloween, and to get in the spirit (spirit - get it? 👻 ) we thought it would be fun t

Jim Bennett 5 Feb 07, 2022
Segger Embedded Studio project for building & debugging Flipper Zero firmware.

Segger Embedded Studio project for Flipper Zero firmware Установка Добавить данный репозиторий в качестве сабмодуля в корень локальной копии репозитор

25 Dec 28, 2022
CO2Ampel - This RaspberryPi project uses weather data to estimate the share of renewable energy in the power grid

CO2Ampel This RaspberryPi project uses weather data to estimate the share of ren

Felix 4 Jan 19, 2022
Self Driving Car Prototype

Package Delivery Rover 🚀 This project is a prototype of Self Driving Car. It's based on embedded systems, to meet the current requirement of delivery

Abhishek Pawar 1 Oct 31, 2021
Pure micropython ESP32 SPI driver for sdcard and screen at the same SPI bus

micropython-esp32-spi-sdcard-and-screen-driver Proof of concept of Pure micropython espidf SPI driver for sdcard with screen at the same SPI bus (exam

Thomas Favennec 7 Mar 14, 2022
Home Assistant custom integration for e-distribución

e-Distribución is an energy distribution company that covers most of South Spain area. If you live in this area, you probably are able to register into their website to get some information about you

VMG 17 Sep 07, 2022
Automate gate/garage door opening via 433.92MHz emitter with Raspberry Pi, Home Assistant and Homekit.

Automate opening your garage door / gate Summary This project sums up how I automated opening my garage door using a Raspberry PI, a 433Mhz emitter, H

Julien Fouilhé 29 Nov 30, 2022
🌱 - WebhookHard◞ Fines Educativos ◟

v1.0.0 WebhookHardware ¿Que es WebhookHardware? WebhookHardware se trata de un proyecto tratado para sacar informacion sobre el hardware de tus victim

3 Jun 14, 2021
Raspberry Pi Pico as a Rubber Ducky

Raspberry-Pi-Pico-as-a-Rubber-Ducky Kurulum Raspberry Pi Pico cihazınız için CircuitPython'u indirin. Boot düğmesine basılı tutarken cihazı bir USB ba

Furkan Enes POLATOĞLU 6 Dec 13, 2022
a fork of the OnionShare software better optimized for lower spec lightweight machines and ARM processors

OnionShare-Optimized A fork of the OnionShare software better optimized for lower spec lightweight machines and ARM processors such as Raspberry Pi or

ALTPORT 4 Aug 05, 2021
Home Assistant component to handle key atom

KeyAtome Home Assistant component to handle key atom, a Linky-compatible device made by Total/Direct-Energie. Installation Either use HACS (default),

18 Dec 21, 2022
A global contest to grow and monitor your own food with Raspberry Pi

growlab A global contest to grow and monitor your own food with Raspberry Pi A capture from phototimer of my seed tray with a wide-angle camera positi

Alex Ellis 442 Dec 23, 2022
An open source two key macro-pad modeled to look like a cartoony melting popsicle

macropopsicle An open source two key macro-pad modeled to look like a cartoony melting popsicle. Build instructions Parts List -1x Top case half (3D p

17 Aug 18, 2022
Raspberry Pi Spectrometer

PySpectrometer 2021-03-05 Raspberry Pi Spectrometer The PySpectrometer is a Python (OpenCV and Tkinter) implementation of an optical spectrometer. The

Les Wright 538 Jan 05, 2023
Universal Xiaomi MIoT integration for Home Assistant

Xiaomi MIoT Raw 简体中文 | English MIoT 协议是小米智能家居从 2018 年起推行的智能设备通信协议规范,此后凡是可接入米家的设备均通过此协议进行通信。此插件按照 MIoT 协议规范与设备通信,实现对设备的状态读取及控制。

1.9k Jan 02, 2023
This Home Assistant custom component adding support for controlling Midea dehumidifiers on local network.

This custom component for Home assistant adds support for Midea dehumidifier appliances via the local area network. homeassistant-midea-dehumidifier-l

Nenad Bogojevic 91 Dec 28, 2022