Help with Arduino keyboard MIDI controller project using the Control Surface library

Hello, I'm making a full functional MIDI controller with my Arduino Mega, I'm using my keyboard of 61 keys, 52 keys will be connected to the pins from 2 to 53, the other 9 will be connecte to pins A0 to A8. The keys are simple push buttons. I was using the code from this video:

But I couldn't change it in order to work the analog pins, so, I decided to do a research and I ended up with a library called Control Surface, it's quite simple and intuitive!

The problem is that with this code I recive this in my Serial-MIDI program:
image

With the code of the video I recived the note in channel 1 and with the velocity value:
image

I need to make this code work like the last photo in order to send the notes:

#include <Control_Surface.h> // Include the Control Surface library
#include <MIDI_Interfaces/SerialMIDI_Interface.hpp>

// Instantiate a MIDI over USB interface.
HairlessMIDI_Interface midi;
 
// Instantiate a CCButton object
CCButton button {A1, {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1},};
 
void setup() {
  Control_Surface.begin(); // Initialize Control Surface
}
 
void loop() {
  Control_Surface.loop(); // Update the Control Surface
} 

You can declare analog pins as digital inputs and they work the same as any other pins.

Simply replace CCButton by NoteButton: Control Surface: NoteButton.ino

2 Likes

Yes! I know, but the problem is that the part of the code that reads the buttons is a loop, and it increases the i index each time it's excuted, and when it goes to the last digital pin, I can't make it jump to the analog pins. It's in the video

Cheers, mate, it worked!!

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