This section is a bit tricky because the modules can operate in one of three modes: serial (debug) mode, MIDI mode, or I2C mode. If you turn one mode on, you must disable the other modes. It is not recommended to jump straight into MIDI mode because it is impossible to debug your controller this way.
If you are using only one module
here are the steps.
- Enable debug mode in the code.
- It is critical that you comment out ALL lines of code which have 'usbMIDI' in them otherwise the code will not compile (annoying, but necessary).
- Select 'serial' device from the Arduino tools->USB type menu.
- Upload your code and open your serial monitor. Ensure the connection speed in 9600bps.
- If your serial monitor is getting flooded with output you have hooked something up incorrectly or have improperly edited to the code to identify which pins are in use. Like I said earlier, it is best just testing one set of components at a time as opposed to all of them at once.
- If your serial monitor is working correctly you should see some output when you interact with the components. This output also informs you which mode number is associated with each pushbutton (so you can change the modes later if necessary).
- Once everything is working in the serial monitor you can now proceed to MIDI.
- Disable debug mode in the code.
- Select 'MIDI' device from the Arduino tools->USB type menu.
- Uncomment all the 'usbMIDI' lines you commented out earlier.
- Your controller is now be ready to send MIDI messages, and your computer should recognize it as a native MIDI device (as easy as that).
- Now I would not recommend jumping directly to hookup with your software, rather, download a free MIDI sniffer (there are many out there) and test your MIDI messages in that first.
- The sniffer, as well as your software, should recognize the device as 'Teensy MIDI'.
- Once you are happy with the MIDI output then proceed to mapping your controller with your desired software.
If you are using more than one module
here are the steps.
- Follow the one module steps above for each module (without them linked together).
- Enable I2C mode on each of the modules except the master module. Never enable I2C on the master module.
- Again, you need to comment out all 'usbMIDI' lines.
- Enable debug mode on the master module. So the master module will be running in serial mode and all other modules will be running in I2C mode.
- Connect all modules together.
- Check the output in the serial monitor. Messages sent from your other modules should now appear in the serial monitor with prefixes '(I2C)'.
- Now enable MIDI mode on only the master module.
- Uncomment all the 'usbMIDI' lines on your master module which you commented out earlier.
- You don't need to make any changes to your other modules, only the master.
- Test your MIDI output in the MIDI sniffer - voila.
- Remember, you must connect all your modules together, then plug in the USB. If you plug in USB before connecting the modules together there will be no communication and all the controllers will freeze.
Alright, this whole operation is a bit convoluted, but once you go through it one time you will understand what is happening here. It is surely annoying you have to continue commenting/uncommenting the 'usbMIDI' lines but it is unfortunately unavoidable.
There is a degree of fickleness you must overcome when trying to upload from Arduino to Teensy, especially when you switch from serial mode to MIDI mode and back. I am not sure what causes these problems, but it is good to know that nothing is broken and if you keep retrying you should have success.
One thing I have noticed about DIY electronics over the years is they never work the first time
. There is always a small soldering blunder or connection error along the way. Don't get discouraged if things don't run smoothly during the first attempt.
Someone asked me, 'can I create a controller which behaves both as a module, and as a standalone controller?'. With the code right now, no
- you would have to upload new code to toggle modes. I am going to try and fix this in the next code version. It will likely require installing one small switch on your PCB.