midi 3 button prototype

const int N_BUTTONS = 3;
byte buttonPin[N_BUTTONS] = {2, 4, 15};
byte buttonState[N_BUTTONS] = {0};
byte buttonPState[N_BUTTONS] = {0};

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

for (int i=0; i < N_BUTTONS; i++) { pinMode(buttonPin[i], INPUT_PULLUP); } } void loop() { // put your main code here, to run repeatedly: buttons(); } void buttons() { for (int i=0; i < N_BUTTONS; i++) { buttonState[i] = digitalRead(buttonPin[i]); if (buttonState[i] != buttonPState[i]) { Serial.print("Button: "); Serial.print(i); Serial.println(); Serial.print(buttonState[i]); Serial.print(" "); buttonPState[i] = buttonState[i]; Serial.println(); } } // Serial.println(); }

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*