DIY Arduino USB MIDI Wind Instrument - Crius MIDI Flute V1

by Crius Digital Studio in Circuits > Arduino

5656 Views, 70 Favorites, 0 Comments

DIY Arduino USB MIDI Wind Instrument - Crius MIDI Flute V1

2020_Sfigmomanometr_elektroniczny.jpg
Crius-Midi-Flute-Thumb-3_2.5.2.jpeg
Crius MIDI Flute v1 - DIY Arduino Midi Wind Instrument [part.1]

I'm sure you ve already seen one Sphygmomanometer that is used for medical purposes and mainly for measuring the blood pressure .

sphygmomanometer (/ˌsfɪɡmoʊməˈnɒmɪtər/ SFIG-moh-mə-NO-mi-tər), a.k.a. a blood pressure monitor, or blood pressure gauge, is a device used to measure blood pressure, composed of an inflatable cuff to collapse and then release the artery under the cuff in a controlled manner,[1] and a mercury or aneroid manometer to measure the pressure. Manual sphygmomanometers are used with a stethoscope when using the auscultatory technique.
A sphygmomanometer consists of an inflatable cuff, a measuring unit (the mercury manometer, or aneroid gauge), and a mechanism for inflation which may be a manually operated bulb and valve or a pump operated electrically.

https://en.wikipedia.org/wiki/Sphygmomanometer

I was looking for a way to monitor air pressure so I can use the data to translate them to MIDI Velocity messagesin order to make a MIDI wind Instrument.

After some research I did I found a pretty affordable Sphygmomanometer Sensor the MPS20N0040-D and began to experiment with the readings of the Arduino pro micro until I made it work like I want.

I designed a Panelized PCB that holds in place the 3 Modules that make the Crius " MIDI Flute"

Crius " MIDI Flute" is a MIDI Wind Instrument consisting of 12 momentary tactile switches for playing the notes and a Sphygmomanometer sensor connected to an Arduino in order to control the Velocity of the MIDI notes simulating the experience of a classic wind Instrument.

  • MIDI Controller is an electronic device for controlling the functions and parameters of VST-Plugin (Virtual S tudio T echnology) or DAW program ( D igital A udio W orkstation) which we play and record music through keys, potentiometers, touch screens and a multitude of sensors.
  • DAW programs are available for PC (Windows, MacOS, Linux) for Tablet and Smartphone.
  • * ( ATTENTION !!! It does not work independently and this is because it does not affect the audio signal but uses the MIDI communication protocol to communicate with the device we have connected).
  • MIDI Controllers are mainly used in music production programs to control VST-Plugins such as musical instruments and effects. However, they are also used in video editing and for the control of professional lighting systems.
  • The MIDI protocol was created in 1982 for communication and synchronization between electronic musical instruments, computers and other electronic devices regardless of the manufacturer.
  • MIDI does NOT transmit beeps other messages that contain information such as the tone, volume of a note, tempo of a track, etc.).

Supplies

2_1.20.1.jpg
  • Arduino Pro Micro Clone x1
  • LM358P OP AMP x1
  • MPS20N0040-D Sensor x1
  • Momentary Switches 12x12mm x12
  • Momentary Switches 6x6mm x2
  • LED 3mm x1
  • Resistors 47kΩ x2
  • Resistor 220kΩ x1
  • PCB Screw Terminals 12 Pins x2
  • PCB Screw Terminals 8 Pins x1
  • PCB Screw Terminals 5 Pins x1
  • PCB Screw Terminals 3 Pins x1
  • Silicone Tube 2x4mm [3mm diameter] x1

ABOUT THE CIRCUIT

78_1.42.1.jpg
83_1.52.1.jpg
86_1.43.2.jpg
80_1.51.1.jpg
85_1.53.1.jpg
84_1.53.2.jpg

The circuit design is pretty simple.

It is a custom Panelized PCB design that consists of 3 modules :

  1. Arduino pro micro Module
  2. Keyboard Module
  3. Sphygmomanometer Sensor Module


On the back side of the PCB you will find some useful build instructions printed on the board.

Also if you look close next to the female header pins I have named each Pin with a “B” letter and the number of each button of the Keyboard Module.

On the back side of the Arduino module I named each Arduino pin with the corresponding “B” pin of the keyboard module.

The Sphygmomanometer Sensor Module is pretty straightforward.

There is an MPS20N0040-D sensor connected to an LM358P dual channel OP AMP through 2 resistors.

The Values of the resistors is not fixed.

You must use the same values for the 2 resistors but the value can vary from 10 - 47kΩ .

Αccordingly to the Value of the resistors changes the sensitivity of the Sensor hardware-wise.

(You can also change the sensitivity from the code)

Finally on the Arduino Module I added 2 small tactile switches in order to change the Octave of the MIDI notes that the Keyboard plays.

There is also an LED that lights up when you select the Default octave.

You can return to the Default Octave by pressing the 2 octave buttons together.


Here are the required Gerber files you need to provide to the PCB manufaturer to order the PCB boards.

For quality and affordable PCBs I suggest you to try the PCBWay manufacturer which I used to order my PCBs and in my opinion are excellent!

Soldering the Components

4_1.59.1.jpg
3_1.63.1.jpg
6_1.71.1.jpg
9_1.75.1.jpg
14_1.81.1.jpg
17_1.86.1.jpg
19_1.87.1.jpg
22_1.92.2.jpg
24_1.96.1.jpg
26_1.100.1.jpg
28_1.105.1.jpg
30_1.106.1.jpg
33_1.115.1.jpg
35_1.117.1.jpg
37_1.120.1.jpg
39_1.122.1.jpg
44_1.130.2.jpg
  1. At fist I will start soldering the 2 small Tctile Switches for the octaves and the 3mm LED to the Arduino Module . Make sure you match the positioning of the LED with the symbol on the silkscreen of the PCB.
  2. Next I will solder the 220 Ω resistor to the positive (longer one) pin fthe LED and cut the neagtive one (shorter one)
  3. I will add a heatshrink tube to avoid any shorts when it touches the PCB.
  4. Now I will solder the male header pins of the Arduino to the PCB. Make sure before soldering the Arduino to the PCB that its top side is facing the bottom side of the Arduino Module of the Crius MIDI Flute (and obviously the usb port is facing out of the PCB).
  5. Solder the 12 pins PCB Screw Terminals next to the Arduino with the holes facing out.
  6. Next I will solder the 12x12mm tactile switches.
  7. Solder the 8 and the 5 pins PCB Secrew Terminals on the Keyboard module.
  8. Now its time to solder the 47 kΩ resistors to the Sensor Module.In this step in order to solder the LM358P chip correctly we must match the mark on the chip with the little white dot of the symbol on the silkscreen of the PCB.
  9. Likewise we must match the notch on the side of the MPS20N0040-D sensor with the corner white mark of the symbol on the silkscreen of the PCB.
  10. Last thing to solder is the 3 pins PCB Screw Terminal on the back side of the Sensor Module.

Wiring the Components

47_1.136.1.jpg
51_1.146.1.jpg
59_1.165.1.jpg
52_1.147.1.jpg
54_1.149.1.jpg
60_1.166.1.jpg
65_1.181.3.jpg
64_1.181.2.jpg
68_1.182.1.jpg
70_1.184.1.jpg
72_1.185.2.jpg
73_1.187.1.jpg
76_1.192.1.jpg
  1. I will start with the Signal pin of the Sensor Module that connects with the A0 pin of the Arduino.
  2. The Ground pin of the Sensor Module with the Ground pin ofthe Arduino and the VCC pin of the Sensor Module with the VCC pin ofthe Arduino.
  3. Next I will connect the wire of the LED that we soldered the 220 Ω Resistor to it before with the A3 pin of the Arduino.
  4. Now I will connect the “B” pins of the Keyboard Module with the “B” pins of the Arduino Module accordingly. Don’t forget also to connect the Ground pin of the Keyboard module with the Ground on the Arduino.
  5. In order for the USB cable to plug into the USB port of the Crius MIDI Flute , we must cut a small piece of the PCB frame.
  6. Place the Silicone Tube to the Sensor and then cut it to the desired length.I create a loop with the Silicone Tube so the end of it is parallel with the board facing out.You could also keep it long and play it like a “Melodica” Instrument.
  7. Finally place the Caps on the Tactile Switches.

Code

1_1.1.1.jpg
1_1.1.2.jpg
1_1.1.3.jpg

To upload the code to the Arduino download the "Crius MIDI Flute.ino" file and open it with the Arduino IDE software.

  1. In order for the code to compile you need to install the MIDIUSB library
  2. Select the Arduino Leonardo Board
  3. Select the Serial port that you have connected the Arduino and
  4. Hit Upload!

Here you can also take a look at the code:

#include <MIDIUSB.h>


int OctaveDown = A1;
int OctaveUp = A2;
int OctaveLed = A3;


int StartOctave = 4;
int CurrentOctave;
int PreviousOctave;


const int NoteButtons = 12;
const int BUTTON_PIN[NoteButtons] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 14, 15};


int buttonCState[NoteButtons] = {};
int buttonPState[NoteButtons] = {};


unsigned long lastDebounceTime[NoteButtons] = {0};
unsigned long debounceDelay = 80;


byte midiCh = 1;
byte note = 0;


int midiMapped = 0;
int lastmidiMapped = 0;


void noteOn(byte channel, byte pitch, byte midiMapped) {
  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, midiMapped};
  MidiUSB.sendMIDI(noteOn);
}


void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOff);
}


void setup() {
  Serial.begin(115200);


  pinMode(OctaveDown, INPUT_PULLUP);
  pinMode(OctaveUp, INPUT_PULLUP);
  pinMode(OctaveLed, OUTPUT);
  CurrentOctave = StartOctave;
  note = 48;


  for (int i = 0; i < NoteButtons; i++) {
    pinMode(BUTTON_PIN[i], INPUT_PULLUP);
  }
}


void loop() {
  Buttons();
  OctaveButtons();
}


void Buttons() {
  if (midiMapped > 5) {
    for (int i = 0; i < NoteButtons; i++) {
      buttonCState[i] = digitalRead(BUTTON_PIN[i]);
      if (buttonCState[i] == LOW) {
        noteOn(midiCh, note + i, midiMapped);
        MidiUSB.flush();
      }
      if (buttonCState[i] == HIGH || midiMapped <= 10) {
        noteOff(midiCh, note + i, 0);
        MidiUSB.flush();
      }
    }
  }
}


void OctaveButtons() {


  int sensorValue = analogRead(A0);
  midiMapped = map(sensorValue, 25, 100, 0, 127);


  int OctaveDownStatus = digitalRead(OctaveDown);
  int OctaveUpStatus = digitalRead(OctaveUp);


  //  Serial.print('\n');
  //  Serial.print(note);
  //  Serial.print('\n');
  //  Serial.print(CurrentOctave);


  if (OctaveDownStatus == LOW && OctaveUpStatus == HIGH) {
    delay(200);
    CurrentOctave = CurrentOctave - 1;
    PreviousOctave = CurrentOctave;
    note = note - 12;
    //    Serial.print('\n');
    //    Serial.print(CurrentOctave);
  }
  if (OctaveUpStatus == LOW && OctaveDownStatus == HIGH) {
    delay(200);
    CurrentOctave = CurrentOctave + 1;
    PreviousOctave = CurrentOctave;
    note = note + 12;
    //    Serial.print('\n');
    //    Serial.print(CurrentOctave);
  }


  if (OctaveDownStatus == LOW && OctaveUpStatus == LOW) {
    delay(200);


    CurrentOctave = 4;
    PreviousOctave = CurrentOctave;
    note = 48;
  }


  if (CurrentOctave == 4) {
    digitalWrite(A3, HIGH);
  }
  if (CurrentOctave != 4) {
    digitalWrite(A3, LOW);
  }
}

Alternative PCB Designs

91_1.55.1.jpg
88_1.54.1.jpg
89_1.54.2.jpg
87_1.56.1.jpg
90_1.56.2.jpg

Here are some versions of the PCB that I designed but decided not to use for vatious reasons but you can take a look and I am really interested to hear your thoughts on them!

This Is the END

I hope you enjoyed the proccess and made one for your self!

You can find everything you need for this project INCLUDING INSTRUCTIONS IN ENGLISH to my website : www.criusdigitalstudio.com

You can find my projects and support me at the following social media and websites:

1.Crius Digital Studio Youtube Channel

2.Crius Digital Studio Thingiverse Profile

3.Crius Digital Studio Github Profile