Hello this is literally my first time coding.. I am basically following what I can find on Arduino forums and PJRC's MIDI section.
What I am looking to build is a usbMIDI device with:
16 arcade buttons
4 "Top Bank Buttons" that will change the MIDI Notes of all 16 arcade buttons
3 "Left side bank buttons" (MIDI Notes stay the same regardless of what "Top bank button" is activated)
3 "Right side bank buttons" (MIDI Notes stay the same regardless of what "Top bank button" is activated)
2 10k Pots
2 10k Faders
The best way I can explain what I mean is using this image provided by DJTechTools for the MIDI FIGHTER 3D
This is the code I have so far (please be gentle its my first ever!) The thought of how to implement this popped in my head as I was copy pasting the basics (or at least the basics from what I understand)
//----------------------------------------------
//------------------START-----------------------
//----------------------------------------------
// Bounce library makes button change detection easy
#include <Bounce.h>
//debugging will print out in serial instead of midi
boolean debugging=false;
boolean traktorrr=false;
//Channel For Midi Messages -
//If, const int channel = 3; doesnt work
//use, int midiChannel=3;
const int channel = 3;
Bounce button1 = Bounce (1, 5) // Bounce (Button#, 5ms debounce)
Bounce button2 = Bounce (2, 5) // 5ms debounce is appropriate for good
Bounce button3 = Bounce (3, 5) // quality mechanical pushbuttons
Bounce button4 = Bounce (4, 5)
Bounce button5 = Bounce (5, 5)
Bounce button6 = Bounce (6, 5)
Bounce button7 = Bounce (7, 5)
Bounce button8 = Bounce (8, 5)
Bounce button9 = Bounce (9, 5)
Bounce button10 = Bounce (10, 5)
Bounce button11 = Bounce (11, 5)
Bounce button12 = Bounce (12, 5)
Bounce button13 = Bounce (13, 5)
Bounce button14 = Bounce (14, 5)
Bounce button15 = Bounce (15, 5)
Bounce button16 = Bounce (16, 5)
Bounce button17 = Bounce (17, 5)
Bounce button18 = Bounce (18, 5)
Bounce button19 = Bounce (19, 5)
Bounce button20 = Bounce (20, 5)
Bounce button21 = Bounce (21, 5)
Bounce button22 = Bounce (22, 5)
Bounce button23 = Bounce (23, 5)
Bounce button24 = Bounce (24, 5)
Bounce button25 = Bounce (25, 5)
Bounce button26 = Bounce (26, 5)
//SKIP PINS 0 & 6 !!!
void setup() {
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(21, INPUT_PULLUP);
pinMode(22, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
}
void loop() {
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();
button7.update();
button8.update();
button9.update();
button10.update();
button11.update();
button12.update();
button13.update();
button14.update();
button15.update();
button16.update();
button17.update(); // "BANK 1" -- 0 = C-1
button18.update(); // "BANK 2" -- 1 = C#-1
button19.update(); // "BANK 3" -- 2 = D-1
button20.update(); // "BANK 4" -- 3 = D#-1
button21.update(); // "LSIDE 1" - 22 = A#0
button22.update(); // "LSIDE 2" - 21 = A0
button23.update(); // "LSIDE 3" - 20 = G#0
button24.update(); // "RSIDE 1" - 25 = C#1
button25.update(); // "RSIDE 2" - 24 = C1
button26.update(); // "RSIDE 3" - 23 = B0
// Note On messages when each button is pressed
if (button1.fallingEdge()) {
usbMIDI.sendNoteOn(60, 99, channel); // 60 = C4
}
if (button2.fallingEdge()) {
usbMIDI.sendNoteOn(61, 99, channel); // 61 = C#4
}
if (button3.fallingEdge()) {
usbMIDI.sendNoteOn(62, 99, channel); // 62 = D4
}
if (button4.fallingEdge()) {
usbMIDI.sendNoteOn(63, 99, channel); // 63 = D#4
}
if (button5.fallingEdge()) {
usbMIDI.sendNoteOn(64, 99, channel); // 64 = E4
}
if (button6.fallingEdge()) {
usbMIDI.sendNoteOn(65, 99, channel); // 65 = F4
}
if (button7.fallingEdge()) {
usbMIDI.sendNoteOn(66, 99, channel); // 66 = F#4
}
if (button8.fallingEdge()) {
usbMIDI.sendNoteOn(67, 99, channel); // 67 = G4
}
if (button9.fallingEdge()) {
usbMIDI.sendNoteOn(68, 99, channel); // 68 = G#4
}