Example program for the Midi5Pin library.

Dependencies:   DebounceIn Midi5Pin mbed

Files at this revision

API Documentation at this revision

Comitter:
mpetrut
Date:
Thu Oct 22 10:08:58 2015 +0000
Commit message:
Initial commit

Changed in this revision

DebounceIn.lib Show annotated file Show diff for this revision Revisions of this file
Midi5Pin.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0798ae015db0 DebounceIn.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DebounceIn.lib	Thu Oct 22 10:08:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
diff -r 000000000000 -r 0798ae015db0 Midi5Pin.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Midi5Pin.lib	Thu Oct 22 10:08:58 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/mpetrut/code/Midi5Pin/#722bbb69c79d
diff -r 000000000000 -r 0798ae015db0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 22 10:08:58 2015 +0000
@@ -0,0 +1,44 @@
+// Demo program that showcases the simple Midi5Pin library
+// capable of MIDI input/ouput using two 5-Pin DIN connectors
+
+#include "mbed.h"
+#include "DebounceIn.h"
+#include "Midi5Pin.h"
+
+AnalogIn distSensor(p20);
+DebounceIn btn_on(p27);
+DebounceIn btn_off(p26);
+Midi5Pin midi(p13, p14);
+
+int main() {   
+    // Initialize buttons
+    btn_on.mode(PullUp);
+    btn_off.mode(PullUp);
+    wait(.001);
+    int old_btn_on=0, new_btn_on;
+    int old_btn_off=0, new_btn_off;
+
+    char controlMessage = (char)(distSensor*127);
+
+    while (1) {  
+        // This reads the serial UART (5-pin Input) and outputs
+        // to the USB virtual com port
+        midi.read();
+        
+        // When this button is pressed, MIDI message is sent to the
+        // 5-Pin serial Output
+        new_btn_on = btn_on;  
+        if ((new_btn_on==0) && (old_btn_on==1)) midi.noteOn(60, 100);
+        old_btn_on = new_btn_on;
+        
+        new_btn_off = btn_off;
+        if ((new_btn_off==0) && (old_btn_off==1)) midi.noteOff(60);
+        old_btn_off = new_btn_off;
+        
+        // Send continuous control messages from the IR distance
+        // sensor to the 5-pin Output
+        if ( abs((char)(distSensor*127)-controlMessage) > 2) {
+            midi.contCtrl(14, (char)(distSensor*127));
+        }
+    }
+}
diff -r 000000000000 -r 0798ae015db0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 22 10:08:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file