Advertisement
pleasedontcode

Arduino MIDI rev_01

Jan 1st, 2024
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Arduino MIDI
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-01 18:13:39
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Send midi data */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <EasyButton.h>
  26. #include <MIDI.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void sendMidiData(void);
  32.  
  33. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  34. const uint8_t Btn1_PushButton_PIN_D2 = 2;
  35.  
  36. /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
  37. EasyButton Btn1_PushButton(Btn1_PushButton_PIN_D2);
  38. MIDI_CREATE_DEFAULT_INSTANCE();
  39.  
  40. void setup(void)
  41. {
  42.   // put your setup code here, to run once:
  43.   Btn1_PushButton.begin();
  44.   MIDI.begin(MIDI_CHANNEL_OMNI);
  45. }
  46.  
  47. void loop(void)
  48. {
  49.   // put your main code here, to run repeatedly:
  50.   Btn1_PushButton.read();
  51.  
  52.   if (Btn1_PushButton.isPressed())
  53.   {
  54.     // Call the function to send MIDI data
  55.     sendMidiData();
  56.   }
  57. }
  58.  
  59. void sendMidiData(void)
  60. {
  61.   // Code to send MIDI data
  62.   // Replace with your own implementation
  63.  
  64.   // Example: Sending a note-on message for note C4 (MIDI note number 60) with velocity 100
  65.   MIDI.sendNoteOn(60, 100, 1);
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement