Button to MIDI Notes - Short Press & Long Press

Hello everyone!
First thing, I'd like to thank all the Arduino users for their contribution and problem solving attitude: I've been developing my projects and acquiring knowledge just reading and browsing this forum. However this time I really need help since I'm stuck.

I am working on a MIDI control surfaces with pots, encoders & buttons.
The aim is to make the buttons sending a specific MIDI note when short-pressed and a different note when long-pressed (say 1 sec).

I couldn't find anything I could adapt.
Could you please help me?
Thanks in advance

GyverButton.h ?

To detect long and short press you can use this method:

Seems like "Press Code" could help.

  • One long press is code 10 (hex), two long presses is 20, etc.
  • One fast press is code F1, two fast presses is F2, etc.
  • Long and short (fast) presses can be combined to give other codes (200+)

Practice and test here ...

Thanks for the prompt answer guys!

Definitely got some hints here, I didn't know the library GyverButton.h

@dlloyd useful tool the simulator! But once I know the hex code of the long and short presses, how do I assign them to the MIDI notes?

Here's the button's sketch:

// Instantiate a NoteButton object
NoteButton button7 = {
  2,                       // Push button on pin 2
  {note(D, 0), CHANNEL_1}, // Note & MIDI channel 
};
 

Thanks!

You could use switch case or if conditions. Here's an example using a unique method to select and play one of eight different notes ...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.