Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <MIDIUSB.h>
  2. #include <DebFuncs.h>
  3.  
  4. const int LEDPIN = 13;
  5. const int INPIN[] = {3,4,5,6};
  6. const int CC_NUM[] = {25,26,27,28};
  7.  
  8. DF::Debounce debounce[4];
  9. DF::IsDROPPED isDropped[4];
  10. DF::IsRAISED isRaised[4];
  11.  
  12. void setup() {
  13. for (int i = 0; i < 4; i++ ) {
  14. pinMode( INPIN[i], INPUT_PULLUP );
  15. }
  16. pinMode( LEDPIN, OUTPUT );
  17. Serial.begin( 115200 );
  18.  
  19. }
  20.  
  21. void loop() {
  22. for (int i = 0; i < 4; i++ ) {
  23. const int DEBOUNCED_DATA = debounce[i]( digitalRead( INPIN[i] ) );
  24. if ( isDropped[i]( DEBOUNCED_DATA ) ) {
  25. controlChange( 0, CC_NUM[i], 127 );
  26. MidiUSB.flush();
  27. digitalWrite( LEDPIN, HIGH );
  28. }
  29. if ( isRaised[i]( DEBOUNCED_DATA ) ) {
  30. controlChange( 0, CC_NUM[i], 0 );
  31. MidiUSB.flush();
  32. digitalWrite( LEDPIN, LOW );
  33. }
  34. }
  35. delay(1);
  36. }
  37.  
  38. void controlChange( byte channel, byte control, byte value) {
  39. midiEventPacket_t event = { 0x0B, 0xB0 | channel, control, value };
  40. MidiUSB.sendMIDI( event );
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement