Go Down

Topic: Arduino Midi Questions (Read 5 times) previous topic - next topic


Hello all, i recently posted on the german forum.Because there are so many talented english speaking members i want to ask my question here also.

I want to build a box.. Powered by 6xAA Accus (6x 2300 mAh should be about 8-8.5 Volts fully charged) which i charge VIA Usb and a 7805 Voltage Regulator.

The Device itself should have a Menu to choose from at the beginning.. something like that:

1. Midi Sequencer
2. Midi Player
3. System Info
4. Save/Load Data

I got some 24LC512 that i saved from another project (MB-6582).
I am a complete newbie to coding and arduino, so i am currently reading Ebooks and trying to figure out what its all about.

I found a page with a 8 Step Sequencer
http://www.larsby.com/johan/?p=9.. but i want to have a 16 Step one, maybe where you can save and load the sequences you made to a 24LC512?! Is this possible ?

On the Midi Player part of the device i am not quite sure because i havent found anything on google that someone made a Midi Player (that plays .mid files) and sends it out via Midi Out ?

On the System Info Part i want to measure the Voltage of the Accus, or at least some number that tells me if its fully loaded or completely down.

I know this is alot of stuff for someone who has no clue what he is talking about, but that is just my goal, achieving it will take some time but maybe some of you have got a clue so that i can start reading through the theoretical parts.

My Arduino Mega 1280 should arrive in 2-3 weeks. I ordered a HD 44780 compliant 20x4 LCD. I planned a case with 6 buttons, 3 pots and 1 encoder.. I dont know if i can maybe use the pots to tweak the midi signals live ? The encoder should be used to change settings inside the menu or the sequencer.

Any help would be very appreciated, i want to learn, but i am better in building stuff than in "planning" and "coding" it.. havent done something familiar yet.. Only build a Midibox SID MB-6582 and a X0xb0x and some little stuff like a small audio amplifier.

Thanks guys.. have a nice weekend


I suggest you check

see what you can work out from there as a start.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.


Thanks i ordered the MidiVox.. I saw that it is controlled by CC Midi Signals. Would it be a problem to rewrite the Code so that i Control the Settings via Potentiometers ? Or is it too difficult for a newbie ? I also want to use normal Buttons for triggering notes because it should be Portable.
http://narbotic.com/files/MidiVox_Healer_v2-100522a.zip <-- Theres the source.. I read through all of the Sources but i dont really get where to modifiy yet.
It will take some time till it arrives. Will have to learn more, i am afraid that it will take a year till i am able to realize what i have planned.
Anyone got a clue ?


All I can give at this stage is general advice.  Since you have some familiarity with software et al I hope I won't come off like I'm talking down with this!  

The idea is to think like an engineer.  Modularize the problem.  Solve the modules.

In other words, instead of trying to get the whole thing working at one swell foop, break it up into smaller semi-independent projects.

For instance, JUST do "hello world" on the LCD.  That will test that your Arduino is working correctly, that sketches are uploading properly, that the LCD works and is properly connected.

Then work on just a single button, then a single pot.  See if you are detecting it and triggering an outside event (flash the LED on pin 13, or write a message to the LCD, or send a serial message you can monitor via the Arduino IDE).

Next send the simplest possible MIDI event.  Write a sketch that doesn't do anything but send "NoteOn channel 1 note #60 velocity 100."  Connect up any MIDI module you have, or computer with MIDI interface...the latter is even better because you can fire up MIDI-Monitor or MIDIpipe or a similar free program and read exactly what it is you sent.

Build the battery charge and monitor circuit.  Test it thoroughly (you don't want unexpected brown-outs to confuse you while you are trying to de-bug later parts of the hardware and software.)

Baby steps, sure, but it is a good way to do any project.  Right now, for instance, I'm making a MIDI-controlled servo.  I wired up, and wrote a short software routine, for the servo first.  Then disconnected that and threw away that sketch.  Wired up and wrote the signal routines for the monitor LEDs, tested those and saved the sketch.  Bread-boarded a MIDI in port, wrote a basic software routine to test that.  I'm currently wiring up the shield so I can test all the major hardware components together.  I'll test them in isolation with quick throwaway sketches, THEN I'll write the production software.

Anyhow, I hope this helps.  There's a lot of steps in hardware and software to what you are considering and a number of "gotchas" that will show up as you go.  Setting intermediate goals isn't just a good way to stay sane -- it is a way to give yourself lots of intermediate victories to keep your spirits up through the long slog!


Hello Nomuse thanks for your reply.

I know that i have to split projects up in little sub projects, i did so in the past. I studied the source of the Arduino Piano Squealer (which uses 3 Pots to control the Filter/Waveform/ and so on insted of 0-10 Midi CC from Midi IN) It uses it like this:

"Since the Pocket Piano has only 3 potentiometers available for control (the 4th one being hardwired to the volume), I use a "page" system to implement series of 3 parameters to fiddle with. To switch "page", use the rightmost note of the A.P (NOT the one under the led, the one left to to it)."

The Midivox is a project made from the Code of the Piano Squealer but uses Midi CC Signals. I tried to find the differences in the code but i dont get it... i am too dumb it seems.
I cant find shematics for the Piano Squealer but it uses Shift Registers for the Note Buttons (maybe for the Potentiometers too ?) So i think i would only have a chance if i could find shematics, copy some of it, and as soon as i got one button working, start from there.

But all i got at the moment is nothing because the Midivox has his focus on Midi IN controlling. I will have to read the Arduino Ebook i have because i just cant find the logical defintion behind the code.

On the Piano Squealer you press a Button and then use the potentiometers.. that is just too much for me to ever find out without knowing where to look at. I tried to google almost every word in the code to find out where those button press could be defined and can be modified, but i just dont get it. I will start building the Hardware side, and then try to find out, shipping till take little longer so i thought i could just start getting into coding, but this doesnt work out without the hardware as far as i can tell.

Thanks to anyone who replied.
*depressed*  :-?


I think i got a start..
I will just let th MidiVox receive Midi Signals and dont modify the code.. But i will try to get my Potentiometers to send CC Signals and connect the Midi Out directly to the Midivox MIDI IN. This should work, this way i can write my own stuff without the need to modify the Midivox Source and without losing the external Midi Control Ability.
Will take some more weeks till i finally get my Arduino from china (this is the last time i order something from china..)

I will read a little more into my ebook as i start figuring out how Midi actually works. I think i can make faster progress as soon as i got the arduino to directly test anything i modify and try.

It is so hard to wait for it to arrive.. i almost explode .
Will keep you updated on my progress, and i hope i can ask if there are some problems. Thanks


Nov 26, 2010, 07:17 am Last Edit: Nov 26, 2010, 07:21 am by CrossRoads Reason: 1
Why did you order all the way from China? (update your profile to show where you're from)

[edit - I looked back, you are in Germany? There are suppliers in Europe - I have seen UK sites listed in the forum. And a bunch in Germany:
Germany: Segor-electronics (search for "Arduino"), ElectroDrome, Watterott Electronic, Elektronikladen | ELMICRO, TinkerSoup, reprap source, Bausteln
Support your local economy!]

If funds are tight, order an RBBB from Modern Devices,
$12.50 and you can be up & running weeks earlier. I think this is one of the least expensive options out there short of just ordering a chip and building from scratch if you have the other parts, or use the internal oscillator.
The unit from China can be your spare, or the one you build into your final unit or something.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.


Hello.. thanks for your reply.. I am from Austria. I made a mistake, i thought i would get it cheaper in china (which actually is true) but they told me that it would take 25 days to ship after i already payed for it. I got to wait a little longer, so long i am reading the Ebook. I found something that might help me.
The only thing that i cant find on google or on the forum is how can i Control different Midi CC lets say... 12 Midi CC with just 4 Potentiometers ? There is something like "switching pages" but i havent found an example. I want to place a Button that changes "Pages" everytime i press it. The LCD Should display on which page i am currently. something like this:
This is the LCD Display when button hasnt been pressed yet and you made some changes with one of the potentiometers

 SAW   64    30   127

after pressing the button it switches to something like this:

   10    20   12     0

This is the code from the book:

Code: [Select]
// Einbinden der Debounce-Library
#include <Debounce.h>
// Einbinden der MidiDuino-Library
#include <MidiUart.h>
#include <Midi.h>
MidiClass Midi;
// Speichern der aktuellen Potentiometerwerte
int potValues[4];
// Die LEDs sind an die Pins 10 und 11 angeschlossen.
int ledPins[2] = { 10, 11 };
// Konfigurieren der Buttons, die an die Pins 12 und 9
// angeschlossen sind
Debounce debounce1(20, 12);
Debounce debounce2(20, 9);
// Speichern der vorigen Tasterwerte
byte prevButtons[2] = { HIGH, HIGH };
// Speichern der aktuellen Tasterwerte
byte newButtons[2];
// MIDI-Tonhöhen, die beim Drücken eines Tasters gesendet werden
int buttonNotes[2] = { 60, 61 };
// Speichern der Controllernummern
int ccNumbers[4] = { 10, 11, 12, 13 };
void setup() {
// Initialisieren der MIDI-Schnittstelle
// Konfigurieren der LED pins als Ausgang
pinMode(ledPins[0], OUTPUT);
pinMode(ledPins[1], OUTPUT);
// Konfigurieren der Buttonpins als Eingänge, mit Pull-up-
// Widerständen

pinMode(12, INPUT);
pinMode(9, INPUT);
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
void loop() {
// Einlesen der Tasterwerte
newButtons[0] = debounce1.read();
newButtons[1] = debounce2.read();
int i;
for (i = 0; i < 4; i++) {
// Auslesen des Potentiometerwertes
int value = analogRead(i);
// Konvertieren des analogen Wertes in den MIDI-Wertebereich
value = map(value, 0, 1023, 0, 127);
// Erkennen, ob der Potentiometer bewegt wurde
if (abs(value - potValues[i]) >= 2) {
// Speichern des neuen Potentiometerwertes
potValues[i] = value;
// Senden der Control Change-Nachricht
MidiUart.sendCC(ccNumbers[i], value);
for (i = 0; i < 2; i++) {
// Hat sich der Tasterwert gegenüber dem vorigen Wert
// geändert, dann wurde der Taster gedrückt oder
// losgelassen.
if (newButtons[i] != prevButtons[i]) {
if (newButtons[i] == LOW) {
// der Taster wurde gedrückt, Note senden und LED
// anschalten
MidiUart.sendNoteOn(buttonNotes[i], 100);
digitalWrite(ledPins[i], HIGH);
} else {
// der Taster wurde losgelassen, Note stoppen und LED
// ausschalten
digitalWrite(ledPins[i], LOW);
// Speichern der neuen Tasterwerte
prevButtons[i] = newButtons[i];

If you could just give me a hint what it would look like i think i can figure the rest out, will search more on google but i dont really know for what to search (how is this page switching called?)
Can i place LCD.PRINT right under the MidiUart.SendCC with something like this:

lcd.setCursor(0, 0)
lcd.setCursor(1, 0)

or am i completely wrong ? I hope that i dont bother anyone here..

Greets from the snow covered austria.


I'm going to defer to the software gurus on this one, this is beyond anything I've tried yet.

It is interesting reading your code with the comments in German mixed in with the Arduino code :-)

No snow in Boston, MA area yet, won't be much longer tho...
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.


Hrm.  Well-commented, but I'd still fix some of those variable names; there's no sense in calling a variable "n3" when you can call it "sensorInterval" or some-such.  Makes it easier to follow the program flow.

I'm not sure what would be the simplest -- and easiest to debug -- version of the potentiometer pages you want.  I assume you are sending each set of values via MIDI CC messages as you are on that page.


int statusByte[4] = {0, 0, 0, 0};   //status byte for MIDI message, one for each knob
digitalRead pageButton;
if pageButton
   mode ++;
   if (mode == 5) then (mode = 0);
switch (mode)
    case 1:
         statusByte(1) = 46x;   // status byte for CC message, in hex
         statusByte(2) = 47x;
         statusByte(3) = 48x;
         statusByte(4) = 49x;
    case 2:
         statusByte(1) = 52x;
         statusByte(2) = 53x
         statusByte(3) = 55x;
         statusByte(3) = 11x;
     case 3:
           /// etc

And then when you send the MIDI message, you pass on the status byte, then the data byte read from that particular knob -- which also can be stored in an array for simplicity;

int knobValue = analogRead(knob);


Hello! Thanks for the example.
I want to use the MidiUart Library as it is easier for me as a complete newbie to arduino. I think i get the Idea behind your example.
So on every Button press it is going one Case up ?! am i right ?
So i could define a MidiCC Channel Change inside those "cases" ?
Well i guess the easiest way is to try it when i get my arduino.. Can anyone recommend a got read on the topic Midi Controlling via Arduino or Sound synthesis ? Because i have to stay on the theoretical side for another 2-3 weeks till the package from china arrives.

I finished the Power supply, Charging, Battery, Case, Speaker, integrated amplifier planning stuff, so there is "only" coding and building left.

So if i want to have multiple functions for a Button (digital) or Potentiometer (analog) i can use something like the example above ?
If the LCD should display where i am at the moment, i have to type the lcd.print inside the corresponding Case ?

Thanks for your time @ all


So on every Button press it is going one Case up ?! am i right ?
So i could define a MidiCC Channel Change inside those "cases" ?

That's exactly the idea.  Each press of the button "toggles" the knob mode between states 1, 2, 3, 4, and then puts it back to 1 with the next press.

And, yes...although I didn't quote the completely correct numbers, you could put the status byte in here (which is the first byte in a MIDI message and the one that tells the receiving device what you want to do with the following data bytes).

Then the analogRead of the knob in question sends the data byte...which, remembering running status, will keep coming in a stream until you signify you've changed the status byte again.  I'm assuming the code snippets you are using deal with multiplexing the buttons, doing running status, conditioning the range, etc.!

(Heh..as we speak I'm trying to write my own running status routine -- I dunno why I'm not using the stock MIDI library, though.)

Well i guess the easiest way is to try it when i get my arduino.. Can anyone recommend a got read on the topic Midi Controlling via Arduino or Sound synthesis ? Because i have to stay on the theoretical side for another 2-3 weeks till the package from china arrives.

Two things you can do right now that seem useful to me;

1) Read up on MIDI.  Especially if you have some keyboards or something around, and there are several free MIDI monitors that will run on your home computer.  Plus you could always write some stuff in Processing (the "sister" to the Arduino IDE.)  The idea is, you want to get a feeling for what a MIDI data stream "looks like" and start thinking in the language.

2) Write software.  You can write and compile in the Arduino IDE without a board connected.  It will check your code for syntax errors before it attempts to upload.  Think of it like a spell check for code; it won't tell you if the code makes sense, but it will catch all the places you declared a variable inappropriately or forgot to close a bracket.

Plus, like I said, you can always write in Processing.  The IDE is very similar, the language similar enough, and the result runs on your home computer.

You could actually write big chunks of the code using Processing to translate mouse clicks or similar to MIDI output, and then 'port that working code to the Arduino when that arrives.

I finished the Power supply, Charging, Battery, Case, Speaker, integrated amplifier planning stuff, so there is "only" coding and building left.

Nice.  Test everything you can, so hardware problems don't sneak up on you during debugging!  (I just went through that on my MIDI controlled servo project; the opto-isolator was having jitter when I was trying to write the MIDI note message parser!)

How are you charging a 9v battery pack off the 5v USB connection, by the way?  Consider starting a thread in Exhibitions to show off how you are doing it.  (I could use that, myself!)

So if i want to have multiple functions for a Button (digital) or Potentiometer (analog) i can use something like the example above ?
If the LCD should display where i am at the moment, i have to type the lcd.print inside the corresponding Case ?

Exactly.   Except you could also test for "if (mode == n)" from within the LCD display subroutines, or where-ever else.  Basically, do stuff like;

if (mode == 3) then LCD.write("Now Adjusting ADSR")

Because the value of mode is global; you declared it within the main program loop, so anywhere within main() -- err, sorry, "loop()"! -- is going to contain a valid value of the current mode.

(A simple trick and a very nice debug tool is just hang four LEDs on to four spare outputs so one ALWAYS lights up to tell you immediately what mode you are in.  But you can do this with an LCD write for your program!)

I find arrays can really simplify life, but sometimes it is easier to read the code if you just have a stack of if/else statements sitting there.

Apologies again for the pseudo-code.  I find it easier to think in pseudo-code, even if I am drifting towards a C-like syntax with it these days.


Nov 26, 2010, 11:29 pm Last Edit: Nov 26, 2010, 11:32 pm by izze Reason: 1
Hey NoMuse.. thanks for your input.

As far as charging a 9V via USB, i found a better Method that is far better.

I bought a Li-Po Battery with 7.4 Volts and 3000 mAH and a charger.
I used a 5V Regulator to get it down to 5 Volt. 5 Volt drives my Speaker with integrated Amplifier. I also plan on putting a Dual USB-A Socket on the Backside to charge any kind of USB device when i am not at home (because the 3000 mAh Li-POs are strong enought to handle that). Because my box should be fully portable and capable of some things that could be quite handy.

I then just connect the charger to my device (the charger got a protection for overcharging which is a far better idea than just letting it hang somewhere for hours without knowing the actual status).

I drive the cooling fan inside my case with the 7,4 Volt. Also the Arduino. I may need a Step Up Converter for the Delay Effect unit i build into the case (it looks like i designed the Ponoko Acrylic Case too small to actually make the effect PCB fit in, but well its a prototype  :D)

I think i will use a lot of LEDs at first because i ordered the Arduino Mega and i have enough free Pins and it makes a lot of things easier at first i think (i got like a 400 LEDs spare in different colours and sizes from earlier projects).

This is my homestudio at the moment.. it is awaiting the arrival of my first selfmade device, hope that it works out. But i guess its a good thing that the arduino is not here yet so i can really focus on learning coding at first.


Wishing you all the best, greets from tyrol / austria  :)


Nice rig!

What little composing I do (especially these days) is for live theater.  Although I still have a rack of sound modules I've pretty much migrated over to virtual instrument libraries (being able to remix tracks at the theater in rehearsal, on a laptop, is very useful).

Most of my gear is for theatrical use...I've used Ozone keyboard, Korg nanokey, and Yamaha QY10 as controllers for MIDI effects, plus I have an Arduino-driven button box that I can put anywhere I need to trigger a MIDI effect from.

I'm pretty excited right now because I'm finally about to add a MIDI-controlled servo to my kit of theatrical tricks.  Its first job will be remote dousing of a video projector.

On my long list of future projects is a USB-powered, MIDI-over-USB button pad.  Just four big red buttons, hard-wired to send MSC (MIDI Show Control) to the host computer.  Basically like a remote faceplate for a CD player; Play, Pause, Rewind, etc.  Except used to control software.

How was the Ponoko experience?  Did you set your housing to "public" so other people can fab it?


Nov 27, 2010, 12:00 am Last Edit: Nov 27, 2010, 12:00 am by izze Reason: 1
The case is currently shipping.. so i havent received it yet. The Ponoko Site is really good and tells you whenever you got some errors inside your vector graphic.

I didnt set it to public because its a prototype that is just for testing purposes.

I will have to redesign as soon as i know how much buttons, potentiometers, LEDs and so on i will have on my final box.

I see endless possibilities with arduino..
I could make LFOs, Arpeggiators and Sequencers just with rewriting the software once i have built it completely (no more opening).

Which adds a lot of comfort to my musical hobby. I may spent 300 dollars now, but after that, every feature that is added is priceless, and increases with my skills. That is something that really satisfies me about Arduino.

I heard about Arduino a year ago, but didnt read into detail.
About 2 weeks ago i read that you actually can built your own musical equipment and stuff, so Arduino got me  8-)

Hopefully i will have success.

Your project seems really interesting, be sure to keep me updated. Servo Controlled midi seems so cool you could have a whole band play on drums and even piano. The Arduino Big Band  ;D

Go Up