by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Program Example 12.6: MIDI messaging with variable scroll speed
00002                                                                    */
00003 #include "mbed.h"
00004 #include "USBMIDI.h”
00005 USBMIDI midi;                        // initialise MIDI interface
00006 AnalogIn Ain(p19);                   // create analog input
00007 
00008 int main() {             
00009     while (1) {    
00010         for(int i=48; i<72; i++) {                 // step through notes
00011             midi.write(MIDIMessage::NoteOn(i));    // note on
00012             wait(Ain);                             // pause
00013             midi.write(MIDIMessage::NoteOff(i));   // note off  
00014             wait(2*Ain);                           // pause
00015         }
00016     }
00017 }
00018