benoit poulain
/
Exemple_Blinky
cours 1
main.cpp
- Committer:
- samux
- Date:
- 2011-11-04
- Revision:
- 1:4108aa07d2a7
- Parent:
- 0:7145560b8847
- Child:
- 2:4505f7d7196e
File content as of revision 1:4108aa07d2a7:
// Hello World example for the USBMIDI library #include "mbed.h" #include "USBMIDI.h" USBMIDI midi; //Bus of buttons BusInOut buttons(p21, p22, p23, p24, p25, p26, p29); int main() { uint8_t p_bus = 0; uint8_t bus = 0; uint8_t add; while (1) { //if buttons state changes, send a MIDI message bus = buttons.read(); if (bus != p_bus) { p_bus = bus; if (p_bus) { for (int i = 0; i < 7; i++) { add = (p_bus & (1 << i)) ? (i + 1) : 0; if (add) { midi.write(MIDIMessage::NoteOn(48 + add)); midi.write(MIDIMessage::NoteOff(48 + add)); } } } } wait(0.001); } }