#include "Button.h"

Button buttonOne(33, 1);
Button buttonTwo(34, 3);
Button buttonThree(35, 5);
Button buttonFour(36, 6);

void setup() {

void loop() {

void onPress(int buttonNumber) {
  Serial.println(" pressed");

  usbMIDI.sendNoteOn(59 + buttonNumber, 127, 1);

void onRelease(int buttonNumber) {
  Serial.println(" released");

  usbMIDI.sendNoteOff(59 + buttonNumber, 0, 1);

Pretty much in void setup() we’re telling the button object which voids to call when it is pressed and when it is released respectively. Pretty much we’re using a function as a variable in order to allow the class to call whichever function is specified. You could theoretically use whatever function you want as the callback, it just makes sense to use something which is related to the event that triggers it.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.