Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DebounceIn Midi5Pin mbed
main.cpp
00001 // Demo program that showcases the simple Midi5Pin library 00002 // capable of MIDI input/ouput using two 5-Pin DIN connectors 00003 00004 #include "mbed.h" 00005 #include "DebounceIn.h" 00006 #include "Midi5Pin.h" 00007 00008 AnalogIn distSensor(p20); 00009 DebounceIn btn_on(p27); 00010 DebounceIn btn_off(p26); 00011 Midi5Pin midi(p13, p14); 00012 00013 int main() { 00014 // Initialize buttons 00015 btn_on.mode(PullUp); 00016 btn_off.mode(PullUp); 00017 wait(.001); 00018 int old_btn_on=0, new_btn_on; 00019 int old_btn_off=0, new_btn_off; 00020 00021 char controlMessage = (char)(distSensor*127); 00022 00023 while (1) { 00024 // This reads the serial UART (5-pin Input) and outputs 00025 // to the USB virtual com port 00026 midi.read(); 00027 00028 // When this button is pressed, MIDI message is sent to the 00029 // 5-Pin serial Output 00030 new_btn_on = btn_on; 00031 if ((new_btn_on==0) && (old_btn_on==1)) midi.noteOn(60, 100); 00032 old_btn_on = new_btn_on; 00033 00034 new_btn_off = btn_off; 00035 if ((new_btn_off==0) && (old_btn_off==1)) midi.noteOff(60); 00036 old_btn_off = new_btn_off; 00037 00038 // Send continuous control messages from the IR distance 00039 // sensor to the 5-pin Output 00040 if ( abs((char)(distSensor*127)-controlMessage) > 2) { 00041 midi.contCtrl(14, (char)(distSensor*127)); 00042 } 00043 } 00044 }
Generated on Wed Jul 20 2022 10:37:27 by
1.7.2
5-Pin DIN MIDI Connector