Rob Toulson / Mbed 2 deprecated RealTimeLab09_MIDIController

Dependencies:   USBDevice mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "USBMIDI.h"
00003 
00004 USBMIDI midi;                        // initialise MIDI interface
00005 DigitalOut LED(p25);
00006 DigitalIn Switch(p14);
00007 AnalogIn Ain(p20);
00008 
00009 int main(){
00010     while (1) {
00011         if (Switch==1) {
00012             int note = 48+72*Ain;                     // calculate note value
00013             midi.write(MIDIMessage::NoteOn(note));    // note on
00014             wait(0.2);
00015             midi.write(MIDIMessage::NoteOff(note));    // note on
00016             LED=0;
00017         }
00018         else {
00019             LED=1;
00020         }               
00021     }
00022 }