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

**URL:** <https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856>\
**Category:** Programming\
**Created:** [August 28, 2023, 3:28pm UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856 "2023-08-28T15:28:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swaggerdani](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@Swaggerdani](https://forum.arduino.cc/u/Swaggerdani)\
**Post date:** [August 28, 2023, 3:28pm UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856/1 "2023-08-28T15:28:06Z")

</div>

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:

[![](https://europe1.discourse-cdn.com/arduino/original/4X/2/8/6/286bacf68d360c76026ec2e27a8bccdb3528708e.jpeg "Construye tu propio controlador MIDI") ](https://www.youtube.com/watch?v=dkFy9S-GjIo&t=1029s)

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](https://europe1.discourse-cdn.com/arduino/original/4X/a/0/2/a029903b398d4d7cd7ea64dce591d424ca84f687.png)

With the code of the video I recived the note in channel 1 and with the velocity value:  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/f/0/b/f0be7f0141750c580ff6f3d1e67a28d0b27f8747.png)

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

```arduino
#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
} 

```

---

<div class="post-metadata">

**Author:** ![blh64](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/blh64/32/605986_2.png) [@blh64](https://forum.arduino.cc/u/blh64)\
**Post date:** [August 28, 2023, 3:32pm UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856/2 "2023-08-28T15:32:57Z")

</div>

> [@Swaggerdani](#):
>
> But I couldn't change it in order to work the analog pins

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

---

<div class="post-metadata">

**Author:** ![PieterP](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@PieterP](https://forum.arduino.cc/u/PieterP)\
**Post date:** [August 28, 2023, 6:56pm UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856/3 "2023-08-28T18:56:05Z")

</div>

> [@Swaggerdani](#):
>
> I need to make this code work like the last photo in order to send the notes:

Simply replace `CCButton` by `NoteButton`: [Control Surface: NoteButton.ino](https://tttapa.github.io/Control-Surface-doc/Doxygen/de/dcc/NoteButton_8ino-example.html)

---

<div class="post-metadata">

**Author:** ![Swaggerdani](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@Swaggerdani](https://forum.arduino.cc/u/Swaggerdani)\
**Post date:** [August 29, 2023, 2:26am UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856/4 "2023-08-29T02:26:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Swaggerdani](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@Swaggerdani](https://forum.arduino.cc/u/Swaggerdani)\
**Post date:** [August 29, 2023, 3:16am UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856/5 "2023-08-29T03:16:45Z")

</div>

Cheers, mate, it worked!!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 25, 2024, 3:22am UTC](https://forum.arduino.cc/t/help-with-arduino-keyboard-midi-controller-project-using-the-control-surface-library/1162856/7 "2024-02-25T03:22:11Z")

</div>

Closed on February 25, 2024, 3:22am UTC

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