- Eventide Audio

Reply To: Cheap DIY Midi Controller

Home Forums Products Stompboxes Cheap DIY Midi Controller Reply To: Cheap DIY Midi Controller

#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/

Show More...

//Built for Ardruino NANO EVERY

 

#include <Control_Surface.h> // Include the library 

 

// Instantiate a MIDI interface

USBDebugMIDI_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#2

PCButton pcBtn3 = {3, {0x03, CHANNEL_1},};  //PC#3

PCButton pcBtn4 = {4, {0x04, CHANNEL_1},};  //PC#4

PCButton pcBtn5 = {5, {0x05, CHANNEL_1},};  //PC#5

PCButton pcBtn6 = {6, {0x06, CHANNEL_1},};  //PC#6

PCButton 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 0x

Ex: = {PHYSICALPIN, {**CCHEXVAL**, CHANNEL_#},{ VALUEWHNPUSHED, VALUEWHENRELEASED }};

*/

CCButton button08 = {8,  {0x10, CHANNEL_1},};  // CC#16

CCButton button09 = {9,  {0x11, CHANNEL_1},};  // CC#17

CCButton button10 = {10, {0x12, CHANNEL_1},};  // CC#18

CCButton button11 = {11, {0x13, CHANNEL_1},};  // CC#19

 

/* Instantiate a latched push button that sends MIDI CC messages for a BOOST function

This still uses a momentary physical switch. Assign to Volume in H9 control

Default values overriden. Adjust to boost strength preference

 */

CCButtonLatched boost = {12, {0x07, CHANNEL_1},{ 127, 80 }};  // CC#7 – VOLUME BOOST

const pin_t BoostLed= {13};  // The LED to display the state of the boost button.

 

/* Instantiate an analog input for an Expression pedal

This ia an analog POT with 5v, Ground and Signal. **may jitter**

 */

CCPotentiometer potentiometer = {A0, {0x0B, CHANNEL_1},}; // CC#11, pot wired to pin A0

 

void setup() {

Control_Surface.begin(); // Initialize main Control Surface code

pinMode(13, OUTPUT);  // assign Led pin as output pin

}

 

void loop() {

Control_Surface.loop(); // Update the main Control Surface

digitalWrite(BoostLed, boost.getState() ? HIGH : LOW); // Update the LED state to reflect the toggled switch state. Match name of led to name of button

}

Show Less...