midi keyboard octave up/down not working

Hi!

I'm new to arduino and also don't know much about MIDI either, i know about analogue electronics but not much about digital, i found a few days ago this project and decided to give it a try in order to make a one octave keyboard to play with my feet (like the moog taurus, can't waint to jam some Rush)

this is the link:

https://fritzing.org/projects/simplest-midi-keyboard?fbclid=IwAR2BmmZsueafXrQLMpDrrqzPZ3-Yi0Da1EXG08A1wcW9YY7XGpI_8wDyClc

Added a line in the begining to start the MIDI to the original code in order to make it work with the most recent library, mounted everything in a protoboard just like in the schematic, all 12 keys work and the synth plays the notes, but can't make work the octave up/down buttons or the pitch bend, also neither serial plotter, serial monitor display anything when said buttons are pressed

Any suggestion? I'd really appreciate it



/*
This sketch is based on example code from ADAFRUIT (Thanks a lot!)
http://www.adafruit.com/blog/2009/10/20/example-code-for-multi-button-checker-with-debouncing/
and uses MIDI library:
http://sourceforge.net/projects/arduinomidilib/


*/
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
#define DEBOUNCE 10  // button debouncer, how many ms to debounce, 5+ ms is usually plenty

// here is where we define the buttons that we'll use. button "1" is the first, button "6" is the 6th, etc
byte buttons[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; // the analog 0-5 pins are also known as 14-19
// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)
// we will track if a button is just pressed, just released, or 'currently pressed' 
byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];

void setup() {
   MIDI.begin(1);              // Launch MIDI with default options
    
  byte i;
  
  // pin13 LED
  pinMode(13, OUTPUT);
 
  // Make input & enable pull-up resistors on switch pins
  for (i=0; i< NUMBUTTONS; i++) {
    pinMode(buttons[i], INPUT);
    digitalWrite(buttons[i], HIGH);
  }
}

void check_switches()
{
  static byte previousstate[NUMBUTTONS];
  static byte currentstate[NUMBUTTONS];
  static long lasttime;
  byte index;

  if (millis() < lasttime) {
     // we wrapped around, lets just try again
     lasttime = millis();
  }
  
  if ((lasttime + DEBOUNCE) > millis()) {
    // not enough time has passed to debounce
    return; 
  }
  // ok we have waited DEBOUNCE milliseconds, lets reset the timer
  lasttime = millis();
  
  for (index = 0; index < NUMBUTTONS; index++) {
    justpressed[index] = 0;       // when we start, we clear out the "just" indicators
    justreleased[index] = 0;
     
    currentstate[index] = digitalRead(buttons[index]);   // read the button
    

    
    if (currentstate[index] == previousstate[index]) {
      if ((pressed[index] == LOW) && (currentstate[index] == LOW)) {
          // just pressed
          justpressed[index] = 1;
      }
      else if ((pressed[index] == HIGH) && (currentstate[index] == HIGH)) {
          // just released
          justreleased[index] = 1;
      }
      pressed[index] = !currentstate[index];  // remember, digital HIGH means NOT pressed
    }
    //Serial.println(pressed[index], DEC);
    previousstate[index] = currentstate[index];   // keep a running tally of the buttons
  }
}


void loop() {
  check_switches();      // when we check the switches we'll get the current state
  
  for (byte i = 0; i < NUMBUTTONS; i++) {
    if (justpressed[i]) {
       MIDI.sendNoteOn(44+i,127,1); 
    }
    if (justreleased[i]) {
      MIDI.sendNoteOff(44+i,127,1); 
    }
  
  }
}

Hello
Do you use all buttons to play notes?
Do you have addtional buttons to control octave up/down and pitch bend?

Hi!
The pcb layout in the second image has 16 buttons, 12 are for the notes (go from D6 to A3 or D13), 2 for pitch up/down and 2 for octave above/below (D2 to D5), which is how i mounted a protoboard

All 12 notes play and start in C4 to B4 but any of the 4 buttons for the pitch or octave do nothing, allegedly the code covers those 4 buttons and 2 potentiometers shown in the pcb layout connected in A4 and A5

i think the issue is in the code as nothing happens in the serial monitor or plotter when the buttons for pitch and octave but it does with the note buttons

Hello,
you may have to check the MIDI coding to be sent in case of control octave up/down and pitch bend.

1 Like

There is nothing in that code that even attempts to do anything with pitch/octave or any potentiometers. Perhaps there is a more complete program somewhere in that project listing. Either that or you have some work to do.

Steve

1 Like