MIDI controller with arcade buttons

Hi! I am building a midi controller to be used with an iPhone and Koala Sampler app.

The device has also an usb hub with audio output and a powerbank. The board used is Teensy LC. There are 23 buttons and 4 leds. The whole project was inspired by youtube user Moby Pixel. His tutorial was very helpful.
Code provided by the author using Control Surface library works great:

I am trying to extend the functionality of the device, but had little succes, since I am new to coding:

**1) 4 smaller buttons should change the midi channel of the 16 buttons below. 4 leds next to the buttons shoud show which one of the 4 channels is selected. **

2) the device shoud be able to switch from vertical to horizontal layout by the bush of a button.

Please help with the coding!


board pin numbers and functions of the buttons


vertical to horizontal switch button


// This project is based on Moby Pixel's video:
// https://youtu.be/K0cbeFYHCZ8

// Original Code Sketch by Nick Culbertson
// https://gist.github.com/NickCulbertson/7961bb91e27e93dc364bff97dbd79d7e

// Software Needed:

// Teensyduino IDE (Program for running Arduino sketches on Teensy):
// https://www.pjrc.com/teensy/td_download.html

// Arduino Legacy IDE (1.8.X)
// https://www.arduino.cc/en/software

// Libraries Needed:

// Control Surface MIDI Library for Arduino
// https://github.com/tttapa/Control-Surface

// MIDIUSB
// https://github.com/arduino-libraries/MIDIUSB


#include <Control_Surface.h> 

USBMIDI_Interface midi;
unsigned int octave = 1;

// Two buttons on the sides that send midi notes on a fixed channel 5. Used for PLAY/REC.
NoteButton button0 {0, {MIDI_Notes::A(octave), CHANNEL_5}};
NoteButton button21 {21, {MIDI_Notes::B(octave), CHANNEL_5}};

// main 16 buttons that send midi notes on channel 1-4, depending on Channel Selection buttons below.
NoteButton button1 {1, {MIDI_Notes::A(octave), CHANNEL_1}};
NoteButton button2 {2, {MIDI_Notes::B(octave), CHANNEL_1}};
NoteButton button3 {3, {MIDI_Notes::C(octave+1), CHANNEL_1}};
NoteButton button4 {4, {MIDI_Notes::D(octave+1), CHANNEL_1}};
NoteButton button5 {5, {MIDI_Notes::E(octave+1), CHANNEL_1}};
NoteButton button6 {6, {MIDI_Notes::F_(octave+1), CHANNEL_1}};
NoteButton button7 {7, {MIDI_Notes::G(octave+1), CHANNEL_1}};
NoteButton button8 {8, {MIDI_Notes::A(octave+1), CHANNEL_1}};
NoteButton button9 {9, {MIDI_Notes::B(octave+1), CHANNEL_1}};
NoteButton button10 {10, {MIDI_Notes::C(octave+2), CHANNEL_1}};
NoteButton button11 {11, {MIDI_Notes::D(octave+2), CHANNEL_1}};
NoteButton button12 {12, {MIDI_Notes::E(octave+2), CHANNEL_1}};
NoteButton button13 {13, {MIDI_Notes::F_(octave+2), CHANNEL_1}};
NoteButton button14 {14, {MIDI_Notes::G(octave+2), CHANNEL_1}};
NoteButton button15 {15, {MIDI_Notes::A(octave+2), CHANNEL_1}};
NoteButton button16 {16, {MIDI_Notes::B(octave+2), CHANNEL_1}};

// 4 Channel Selection buttons. When pressed, main 16 buttons change to the respective midi channel. Respective led lights up. Should not send midi notes.
NoteButton channel1 {17, {MIDI_Notes::F_(octave+3), CHANNEL_1}};
NoteButton channel2 {18, {MIDI_Notes::G(octave+3), CHANNEL_1}};
NoteButton channel3 {19, {MIDI_Notes::A(octave+3), CHANNEL_1}};
NoteButton channel4 {20, {MIDI_Notes::B(octave+3), CHANNEL_1}};

// 4 LEDS that indicate what midi channel is currently selected.  
//PINS: 
//22 (lights up when channel1 button on pin 17 is pressed) 
//23 (lights up when channel2 button on pin 18 is pressed) 
//24 (lights up when channel3 button on pin 19 is pressed)
//25 (lights up when channel4 button on pin 20 is pressed)

// One button that switches the orientation of the device from horizontal to vertical and back. Only the main 16 buttons are affected. Shoud not send midi notes.
NoteButton orientationbutton {26, {MIDI_Notes::A(octave), CHANNEL_5}};

void setup() {
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop(); 
}

You might want to use banks: Control Surface: Frequently Asked Questions

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.