Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <MIDIUSB.h>
- #include <DebFuncs.h>
- const int LEDPIN = 13;
- const int INPIN[] = {3,4,5,6};
- const int CC_NUM[] = {25,26,27,28};
- DF::Debounce debounce[4];
- DF::IsDROPPED isDropped[4];
- DF::IsRAISED isRaised[4];
- void setup() {
- for (int i = 0; i < 4; i++ ) {
- pinMode( INPIN[i], INPUT_PULLUP );
- }
- pinMode( LEDPIN, OUTPUT );
- Serial.begin( 115200 );
- }
- void loop() {
- for (int i = 0; i < 4; i++ ) {
- const int DEBOUNCED_DATA = debounce[i]( digitalRead( INPIN[i] ) );
- if ( isDropped[i]( DEBOUNCED_DATA ) ) {
- controlChange( 0, CC_NUM[i], 127 );
- MidiUSB.flush();
- digitalWrite( LEDPIN, HIGH );
- }
- if ( isRaised[i]( DEBOUNCED_DATA ) ) {
- controlChange( 0, CC_NUM[i], 0 );
- MidiUSB.flush();
- digitalWrite( LEDPIN, LOW );
- }
- }
- delay(1);
- }
- void controlChange( byte channel, byte control, byte value) {
- midiEventPacket_t event = { 0x0B, 0xB0 | channel, control, value };
- MidiUSB.sendMIDI( event );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement