by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp@0:5a4c19d2c258, 2013-06-16 (annotated)
- Committer:
- robt
- Date:
- Sun Jun 16 15:30:58 2013 +0000
- Revision:
- 0:5a4c19d2c258
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robt | 0:5a4c19d2c258 | 1 | /* Program Example 12.6: MIDI messaging with variable scroll speed |
robt | 0:5a4c19d2c258 | 2 | */ |
robt | 0:5a4c19d2c258 | 3 | #include "mbed.h" |
robt | 0:5a4c19d2c258 | 4 | #include "USBMIDI.h” |
robt | 0:5a4c19d2c258 | 5 | USBMIDI midi; // initialise MIDI interface |
robt | 0:5a4c19d2c258 | 6 | AnalogIn Ain(p19); // create analog input |
robt | 0:5a4c19d2c258 | 7 | |
robt | 0:5a4c19d2c258 | 8 | int main() { |
robt | 0:5a4c19d2c258 | 9 | while (1) { |
robt | 0:5a4c19d2c258 | 10 | for(int i=48; i<72; i++) { // step through notes |
robt | 0:5a4c19d2c258 | 11 | midi.write(MIDIMessage::NoteOn(i)); // note on |
robt | 0:5a4c19d2c258 | 12 | wait(Ain); // pause |
robt | 0:5a4c19d2c258 | 13 | midi.write(MIDIMessage::NoteOff(i)); // note off |
robt | 0:5a4c19d2c258 | 14 | wait(2*Ain); // pause |
robt | 0:5a4c19d2c258 | 15 | } |
robt | 0:5a4c19d2c258 | 16 | } |
robt | 0:5a4c19d2c258 | 17 | } |
robt | 0:5a4c19d2c258 | 18 |