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.
main.cpp
00001 #include "mbed.h" 00002 #include "USBMIDI.h" 00003 00004 USBMIDI midi; 00005 00006 //Bus of buttons 00007 BusInOut buttons(p21, p22, p23, p24, p25, p26, p29); 00008 00009 int main() { 00010 uint8_t p_bus = 0; 00011 uint8_t bus = 0; 00012 uint8_t add; 00013 while (1) { 00014 //if buttons state changes, send a MIDI message 00015 bus = buttons.read(); 00016 if (bus != p_bus) { 00017 p_bus = bus; 00018 if (p_bus) { 00019 for (int i = 0; i < 7; i++) { 00020 add = (p_bus & (1 << i)) ? (i + 1) : 0; 00021 if (add) { 00022 midi.write(MIDIMessage::NoteOn(48 + add)); 00023 midi.write(MIDIMessage::NoteOff(48 + add)); 00024 } 00025 } 00026 } 00027 } 00028 wait(0.001); 00029 } 00030 }
Generated on Thu Jul 14 2022 03:51:23 by
