Real Time Lab Program

Dependencies:   USBDevice mbed

Committer:
robt
Date:
Sun Jan 25 16:32:00 2015 +0000
Revision:
0:bf7edc68c57c
Real Time Lab Program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:bf7edc68c57c 1 #include "mbed.h"
robt 0:bf7edc68c57c 2 #include "USBMIDI.h"
robt 0:bf7edc68c57c 3
robt 0:bf7edc68c57c 4 USBMIDI midi; // initialise MIDI interface
robt 0:bf7edc68c57c 5 DigitalOut LED(p25);
robt 0:bf7edc68c57c 6 DigitalIn Switch(p14);
robt 0:bf7edc68c57c 7 AnalogIn Ain(p20);
robt 0:bf7edc68c57c 8
robt 0:bf7edc68c57c 9 int main(){
robt 0:bf7edc68c57c 10 while (1) {
robt 0:bf7edc68c57c 11 if (Switch==1) {
robt 0:bf7edc68c57c 12 int note = 48+72*Ain; // calculate note value
robt 0:bf7edc68c57c 13 midi.write(MIDIMessage::NoteOn(note)); // note on
robt 0:bf7edc68c57c 14 wait(0.2);
robt 0:bf7edc68c57c 15 midi.write(MIDIMessage::NoteOff(note)); // note on
robt 0:bf7edc68c57c 16 LED=0;
robt 0:bf7edc68c57c 17 }
robt 0:bf7edc68c57c 18 else {
robt 0:bf7edc68c57c 19 LED=1;
robt 0:bf7edc68c57c 20 }
robt 0:bf7edc68c57c 21 }
robt 0:bf7edc68c57c 22 }