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.

Input.ino 1.4KB

3 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <MIDI.h>
  2. MIDI_CREATE_DEFAULT_INSTANCE();
  3. // -----------------------------------------------------------------------------
  4. // This example shows the old way of checking for input messages.
  5. // It's simpler to use the callbacks now, check out the dedicated example.
  6. #define LED 13 // LED pin on Arduino Uno
  7. // -----------------------------------------------------------------------------
  8. void BlinkLed(byte num) // Basic blink function
  9. {
  10. for (byte i=0;i<num;i++)
  11. {
  12. digitalWrite(LED,HIGH);
  13. delay(50);
  14. digitalWrite(LED,LOW);
  15. delay(50);
  16. }
  17. }
  18. // -----------------------------------------------------------------------------
  19. void setup()
  20. {
  21. pinMode(LED, OUTPUT);
  22. MIDI.begin(); // Launch MIDI, by default listening to channel 1.
  23. }
  24. void loop()
  25. {
  26. if (MIDI.read()) // Is there a MIDI message incoming ?
  27. {
  28. switch(MIDI.getType()) // Get the type of the message we caught
  29. {
  30. case midi::ProgramChange: // If it is a Program Change,
  31. BlinkLed(MIDI.getData1()); // blink the LED a number of times
  32. // correponding to the program number
  33. // (0 to 127, it can last a while..)
  34. break;
  35. // See the online reference for other message types
  36. default:
  37. break;
  38. }
  39. }
  40. }