Home › Forums › Products › Stompboxes › Cheap DIY Midi Controller › Reply To: Cheap DIY Midi Controller
August 6, 2020 at 8:56 pm
#155492
camn
Participant
ok people. cleanest codeset yet.
Incluses a spot for an expression pedal (or multiples) as well as a VOLUME BOOST with an LED toggling it’s state. This might break with a Preset switch, but will reset if you hit it a couple times.
Lets see if I can get it to paste correctly. If not, download here:
http://thenorthwestenterprise.com/files/Expanded_Published.ino
//midi.controller for eventide H9//by Cameron Newell @the.nw.enterprise, http://thenorthwestenterprise.com///Library Source https://github.com/tttapa/Control-Surface//Built for Ardruino NANO EVERY#include <Control_Surface.h> // Include the library// Instantiate a MIDI interfaceUSBDebugMIDI_Interface usbmidi(115200); // uncomment this for serial monitor in ide//HardwareSerialMIDI_Interface serialmidi = {Serial1, MIDI_BAUD}; //uncomment this for 5-pin operation- this sends on TX **may need to rename Serial1 vs Serial//USBMIDI_Interface midi; // uncomment for native MIDI over USB//HairlessMIDI_Interface hair (); // uncomment this for Hairless/* Instantiate PCButtons that read the inputs from a push button and sends out a MIDI Program Change message when they are pressed.Ex: = {**PHYSICALPIN**, {**PCHEXVALUE**, CHANNEL_#},};This setup matches PC to PIN Number*/PCButton pcBtn2 = {2, {0x02, CHANNEL_1},}; //PC#2PCButton pcBtn3 = {3, {0x03, CHANNEL_1},}; //PC#3PCButton pcBtn4 = {4, {0x04, CHANNEL_1},}; //PC#4PCButton pcBtn5 = {5, {0x05, CHANNEL_1},}; //PC#5PCButton pcBtn6 = {6, {0x06, CHANNEL_1},}; //PC#6PCButton pcBtn7 = {7, {0x07, CHANNEL_1},}; //PC#7/*Hotswitch or other cc function will fire 127 on press and 0 on release by default. This is overridable. Use a momentary switch, like the others.Assicn CC number from here, precede HEX with 0xEx: = {PHYSICALPIN, {**CCHEXVAL**, CHANNEL_#},{ VALUEWHNPUSHED, VALUEWHENRELEASED }};*/CCButton button08 = {8, {0x10, CHANNEL_1},}; // CC#16CCButton button09 = {9, {0x11, CHANNEL_1},}; // CC#17CCButton button10 = {10, {0x12, CHANNEL_1},}; // CC#18CCButton button11 = {11, {0x13, CHANNEL_1},}; // CC#19/* Instantiate a latched push button that sends MIDI CC messages for a BOOST functionThis still uses a momentary physical switch. Assign to Volume in H9 controlDefault values overriden. Adjust to boost strength preference*/CCButtonLatched boost = {12, {0x07, CHANNEL_1},{ 127, 80 }}; // CC#7 – VOLUME BOOSTconst pin_t BoostLed= {13}; // The LED to display the state of the boost button./* Instantiate an analog input for an Expression pedalThis ia an analog POT with 5v, Ground and Signal. **may jitter***/CCPotentiometer potentiometer = {A0, {0x0B, CHANNEL_1},}; // CC#11, pot wired to pin A0void setup() {Control_Surface.begin(); // Initialize main Control Surface codepinMode(13, OUTPUT); // assign Led pin as output pin}void loop() {Control_Surface.loop(); // Update the main Control SurfacedigitalWrite(BoostLed, boost.getState() ? HIGH : LOW); // Update the LED state to reflect the toggled switch state. Match name of led to name of button}