Skip to content

Detecting what note has been pressed on a MIDI keyboard. #277

Answered by franky47
Kinokoda asked this question in Q&A
Discussion options

You must be logged in to vote

Check out the Callbacks example, it does just that.

The handleNoteOn function will be called when the Arduino receives a NoteOn, and the pitch parameter will be the note number (between 0 and 127, check out this table to map it to human-friendly note numbers).

void handleNoteOn(byte channel, byte pitch, byte velocity)
{
// Do whatever you want when a note is pressed.
// Try to keep your callbacks short (no delays ect)
// otherwise it would slow down the loop() and have a bad impact
// on real-time performance.
}

Replies: 1 comment 15 replies

Comment options

You must be logged in to vote
15 replies
@franky47
Comment options

@Kinokoda
Comment options

@Kinokoda
Comment options

@franky47
Comment options

@Kinokoda
Comment options

Answer selected by Kinokoda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants