Arduino MIDI Channel Monitor

Whilst messing about with MIDI drums at one point it would have been really useful to be able to check which MIDI channels had messages, so I thought it would be useful to have a simple MIDI channel monitor.  The idea is that you have 16 LEDs, one for each MIDI channel, and if any MIDI messages are detected on that channel, light up the corresponding LED.

  • In Part 2 I commit the idea to stripboard.

I already have a good starting place for this – the Arduino MIDI Note Monitor, but I wanted something a bit smaller so found some neat 8-LED “bars” that I decided to use with an Arduino Nano.

Warning! I strongly recommend using an old or second hand keyboard for your MIDI experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Nano (but you could use an Uno)
  • 2x 8 LED “bars” (or you could use 16 separate LEDs and associated resistors)
  • Breadboard and jumper wires
  • MIDI receive module (see Arduino MIDI Interfaces)

The Circuit

There isn’t really a circuit in my case, as I was using these:

2020-07-20 17.21.55

They are basically 8 LEDs connected via a built-in surface mount resistor to a common GND.  You just need to connect each Dn pin header to an appropriate IO pin on your board.

If you are using separate LEDs and resistors, then you’ll basically need to build two of the Arduino MIDI Note Monitor circuits and connect them to A0 to A5 and two spare digital pins.

So I was hoping to use my LED “bars” directly connected to an Arduino Nano as it has at least 8 IO pins on each side. Unfortunately there were a few issues:

  • There aren’t enough digital pins, but as you can use the analog pins in a digital mode, I was planning on using A0 to A7 as digital IO on one side and D2 to D9 on the other.
  • However – you can’t use A6 and A7 as digital outputs…
  • Also, there isn’t a GND pin in the right place (at least on the analog pin side, you could in theory use a digital IO pin permanently set LOW as a GND on the digital pin side).

So it wasn’t a direct “plug in and it works” use.  In the end I bent the two GND pins back underneath the board so they could be connected via a jumper wire.

I also bent D1 and D2 on one of the boards so that instead of linking to A6 and A7, I used a jumper wire to thread them round to D11 and D12.  The result is shown below.

2020-07-20 17.08.29

In terms of receiving the MIDI signal, it just needs a connection to the RX pin of the Nano. This could be via a MIDI receive module or it could be directly from the TX pin of another Arduino.

The Code

I’ve used the Arduino MIDI Library again but this time in its “simple” polling mode – I just check if there is any MIDI data each time through the Arduino’s loop.  If a message is detected I check to see if it is one of the MIDI channel related messages and if so pull out the channel number.  Then this is used to turn on the appropriate LED.  I create a list of pin numbers, one for each of the 16 MIDI channels, so I can work out which pin to turn HIGH by using the MIDI channel number less 1 – recall MIDI channels go from 1 to 16, but I want an index into my list of 0 to 15.

The LED needs to be one for a short period of time to be noticed, so I create another list of “count down timers” – one for each channel/LED.  When the LED is turned on the count down timer is set and then every time round the loop it will decrement the counter.  When it reaches zero, I turn off the LED then set the timer value to -1 which I use as an indication that the timer isn’t currently in use.

On start-up there is a simple count up through the LEDs so you can work out which LED corresponds to which MIDI channel.

That is about it.

Find it on GitHub here.

Closing Thoughts

I was hoping for a more self-contained unit, but this is pretty close.  It wouldn’t take much work with a piece of stripboard to eliminate the wires and leave me with a single “plug in and go” unit that I can then use either directly on the Arduino RX lines or via a MIDI receive module.

A future enhancement might be to use multi-colour LEDs to indicate the types of messages received or even add a small display panel that can show basic text.

Kevin

Leave a comment