secret
Created

  • Download Gist
BoxController.ino
Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
#include <MIDI.h>
 
void HandleNoteOn(byte channel, byte pitch, byte velocity) {
if (velocity != 0) { // Filter out note_off
switch(pitch) {
case 60:
digitalWrite(6, HIGH);
break;
case 62:
digitalWrite(7, HIGH);
break;
case 64:
digitalWrite(8, HIGH);
break;
case 65:
digitalWrite(9, HIGH);
break;
case 67:
digitalWrite(10, HIGH);
break;
}
} else { // Is note off
switch(pitch) {
case 60:
digitalWrite(6, LOW);
break;
case 62:
digitalWrite(7, LOW);
break;
case 64:
digitalWrite(8, LOW);
break;
case 65:
digitalWrite(9, LOW);
break;
case 67:
digitalWrite(10, LOW);
break;
}
}
}
 
void HandleNoteOff(byte channel, byte pitch, byte velocity) {
switch(pitch) {
case 60:
digitalWrite(6, LOW);
break;
case 62:
digitalWrite(7, LOW);
break;
case 64:
digitalWrite(8, LOW);
break;
case 65:
digitalWrite(9, LOW);
break;
case 67:
digitalWrite(10, LOW);
break;
}
}
 
void setup() {
// Initiate MIDI communications, listen to all channels
MIDI.begin(MIDI_CHANNEL_OMNI);
// Connect the HandleNoteOn function to the library, so it is called upon reception of a NoteOn.
MIDI.setHandleNoteOn(HandleNoteOn); // Put only the name of the function
MIDI.setHandleNoteOff(HandleNoteOff);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
 
void loop() {
// Call MIDI.read the fastest you can for real-time performance.
MIDI.read();
}

Thanks for this.. I want to trigger some solenoids to play on some drums... The hardware is not hard, but I'm no coder.. Couple questions if you don't mind.. what does "case" mean? also, it says "midi omni" and that it listens to ALL midi channels.. did you create your own midi sequence, and only use one channel? have you tried to put other midi songs in there? how did it work? is there a place on the web that has a list of single channel midi tunes?? :) thanks for any help. E

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.