Single Pin MIDI Channel Selector – Part 2

As I mentioned in the Single Pin MIDI Channel Selector it would be nice to use a “DIP switch” on a small circuit board to give me my MIDI channel selection switch.  Here is a small board that can plug directly into an Arduino’s headers.

DIP Switch

Warning! I strongly recommend using old or second hand equipment for your 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 Uno
  • 1x 4 way DIP “slider” switch
  • 1x 1k resistor
  • Sequence of 4 resistors, each approx twice the value of the previous one (I used 1k, 2k1, 4k7, 8k2)
  • 6×6 proto board

The Circuit

SinglePinMIDIChannelSelector-PCB_bbSinglePinMIDIChannelSelector-PCB_schem

The idea is to place the switches on one side and the resistors on the other.  The switches have one common terminal connected to 5V, then each individual other terminal connected to one of the resistors. The resistors come to a common point that links to A0 and to GND via an additional 1k resistor.

There are thus three pin connections required to the Arduino – 5V, GND and A0.  If a 6-hole wide piece of proto board is used, then A0 goes at one end and 5V and GND at the other and it will fit perfectly across the 5V-GND-GND-VIN-space-A0 headers on the Uno.

SinglePinMIDIChannelSelector-PCB-detail_bb

In order to prevent shorts with the resistors, I soldered the common ends together off the board and covered them in heat-shrink before soldering them to the board.  Here are some photos.

Note that my build was slightly different in the end as I moved the switches across to one side of the proto board which let me add a small 2×2 header to break out additional connections to 5V and GND, which is always useful them mucking about with Arduinos.

I also used a 4-way stacking header to bring the power and ground pins through for other uses, even though one of the GND pins and the VIN pin isn’t used on the board itself.

The Code

This uses the exact same code as for the Single Pin MIDI Channel Selector, and as I’m using the same resistor values there is no calibration or adjustment required. It just works fine read the MIDI channel values from A0.

Note that the order of the switches is “backwards” with regards to counting in binary.  For me, it made more sense that switch 1 was the least significant bit and switch 4 the most.  But it is up to you which way round you put your resistors and then how you interpret the switches!

This means that channel 1 is “all switches off”, channel 2 is “switch 1 on”, channel 4 is “switches 1 and 2 on”, channel 9 is “switch 4 on” and so on up to channel 16 being “all switches on”.

Find it on GitHub here.

Closing Thoughts

This is a bit rough-and-ready even by my standards, and it is still a little clunky in use, but it works and is certainly more useful than four slider switches on a solderless breadboard.

This is another one that would make a great custom PCB if I ever get around to deciding that I’d like to work out how to make one.

A variant of this – it might work pretty well as a “vertical” board – plugging in vertically into an Arduino rather than horizontally as it does right now.

Kevin

Leave a comment