PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Basic_IO.ino 745B

3 years ago
12345678910111213141516171819202122232425
  1. #include <MIDI.h>
  2. // Simple tutorial on how to receive and send MIDI messages.
  3. // Here, when receiving any message on channel 4, the Arduino
  4. // will blink a led and play back a note for 1 second.
  5. MIDI_CREATE_DEFAULT_INSTANCE();
  6. void setup()
  7. {
  8. pinMode(LED_BUILTIN, OUTPUT);
  9. MIDI.begin(4); // Launch MIDI and listen to channel 4
  10. }
  11. void loop()
  12. {
  13. if (MIDI.read()) // If we have received a message
  14. {
  15. digitalWrite(LED_BUILTIN, HIGH);
  16. MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
  17. delay(1000); // Wait for a second
  18. MIDI.sendNoteOff(42, 0, 1); // Stop the note
  19. digitalWrite(LED_BUILTIN, LOW);
  20. }
  21. }