Hello there fellow experimentalist. This article will show you how to easily build your own USB midi-controller using a
Teensy 2.0 as your main mothership.
All you need is a Teensy 2.0, cables and a couple of controllers of your choice. In our case the controller will have
3 Knobs (B10K), 3 Sliders (B10K), 5 flip switches and 2 arcade buttons. I have designed the controller to be as modular as possible.
The controllers all have individual strips on the panel and are connected to the teensy with headers so that they are easy to replace if so wanted.
HOW THINGS WORK!?
This thing works like this: The teensy acts as a USB HID Device, in this case a Midi-Device, and read the values from the buttons and knobs etc and send them as midi-data to the computer. No hassle. I should mention that the Teensy can act as any type of HID device, (Keyboard, Mouse, Game pad, Midi Device) and is therefor very handy for this kind of project. (It can also be used to build cool arcade machines!)
Anyway. To be able to read the values from all your cool hardware there are two kinds of inputs: Digital and Analog.
Digital is for Buttons and switches, in other words things that only have a on or off state (0 or 1). And it works like this: One leg of the button is connected to GND and the other is connected to the Digital input. The teensy checks wich state the button is in. If it is pressed down the digital input pin and GND are connected and then the program sends a value out as midi through the USB-Cable. Simple as pancakes.
The analog input is for potensiometers, sliders, knobs, light sensors etc, these are controllers with a range of values not only on or off. Normally it gives you values between 0 and 1023. And it works like this:
The potensiometer has three lugs, these are connected as follows: lug 1 – GND, lug 2 – Analog In, lug 3 – +5 volt.
The teensy now reads wich position the potensiometer is at by measuring how much voltage it gets on the analog input pin. If the potensiometer is moved to the GND-pin then the value will be zero, if its moved to the opposite side (+5volt) then the value will be 1023, if it is some where in between the value will as well. And that is how you read analog inputs. Fantastic!
BUILD THIS THING!
Lets look at how to assemble the controller.
First you should mount all your thingies on the panels like on the picture below. Nice and tidy. This makes soldering so much easier. And its easy and fun and makes the thing look good and you´ll be motivated to continue building. (btw, you should probably have the panels separately when you solder them but its fun to put them together to see how the finished thing is gonna look.)
PROGRAMMING THE TEENSY
Allright, when spririts still are high lets program the Teensy! you will need to install two things on your computer:
1, Arduino Software, the program that is used to write code and upload it for arduino.
2, Teensy Loader, an addon to the Arduino Software wich lets you use it to upload for the Teensy.
When these are installed open this piece of code: CODE
Choose Teensy as your device and then choose Midi Device as your type.
Then lets take a look at the circuit board for the teensy. Place the female headers like i have done on the picture below, make sure that they are straight otherwise the teensy might not fit and its not cool if you have to bend them to much. Then solder them like shown on this pictures below. This makes you able to connect your headers in a simple way. If you dont like making big blobs of solder for the GND and 5Volt rail you could use a leg of a resistor and bridge them all.
(resistor legs are very handy!)
When this is done you should start working on the sliders since they are the trickiest part, when you are done with them its smooth sailing!
Solder a Black cable to all the lugs named 1 and a Red cable to all named 3. These will be connected to the GND and the +5volt rails. Look at the pictures below. It will make sense. When you are done with that you should take the purple cable and solder to the lug called 2. This is the ones that will run to the Teensys analog in ports so you shouldnt solder them together.
Now lets solder the headers. They are the little pins that are connected to the female headers on the circuit board. There should be one for each cable. One for the black GND, one for the RED +5volt and Three for the analog in. They can be a bit sneaky to get right, a nice trick is to bend the cable in to a little hook and holding it around the header while heating it and applying solder. The picture below shows all the headers connected to the board as they should be if they are to work with the code provided by me. (oh and make sure they dont touch each other)
If you have finished a module you can actually test it out directly by connecting the right header at the right place. No need to be done with all of them to see if it works or not. If you have uploaded the midi-controller program to the teensy then it should now act as one if you plug it in to a computer and you should be able to test if the thing works in your favorite program. (probably PD or MAX/MSP)
Use THIS max-patch to test your thingy!
Now lets look at the knobs/potensiometers. They work the same way as the sliders. Solder them as shown in the picture. You should have gotten the hang of it by now. Black and Red cable on the outer lugs, green in the middle. Then headers. Connect to teensy – should work. Magic!
Allright, time for the Switches. Use resistor legs to bridge all legs on one side of the switches. (look at pictures below)
These will go to GND so solder the black wire at the last switch. Then solder the orange cables to the center lugs. These will go to Digital in. Now add headers. one for the black wire and five for the center cables. Connect, try out, enjoy!
Arcade Buttons: For these we will use Blade Receptables to connect to the Arcade buttons. These are nice because you dont have to solder them if you dont want to. Just put the cable inside the red plastic part and squeaze it with some kind of pliers. Connect the two black ones together as on the picture and put them on the buttons, then connect the blue cables to the other connector of the button. add headers to the cables. Look at pictures, connect, enjoy!
CONNECT AND ASSEMBLE
Now you should have soldered everything together and probably put the modules in the frame as o the picture below.
If everything is connected to the teensy as on this picture it should work with the provided software. Its time to assemble the box and when you are done with that you can start playing around with your new controller.
/Niklas – Devsound.