Ableton Live USB Midi Controller With Arduino MEGA

Hello Guys,
I'm an equipment designer and I've designed a midi controller that works just like Ableton Push + 2 Xone K2s To control instruments and FX and sequencers
The Project has 6 Multiplexers with 16 Input/Output Pins .. 3 of them are analog inputs total of 48 analog inputs .. 2 of them are digital inputs total of 32 buttons & 1 multiplexer is for digital outputs for the 16 LEDs for the sequencer ..
I got everything connected the right way and it's totally good looking circuit with small amount of complexity..

I need a serious help in coding the device because in my country no one know anything about using Arduino as a midi controller and all projects online are so limited and using certain chips and ways ...
the main chip is Arduino Mega 2560 Pro Embed CH340G – ATmega2560-16AU Development Board ... Multiplexers are 16-Channel Analog Digital Multiplexer Breakout Board (CD74HC4067)
I wanna know how to identify inputs and outputs to the chip and tell them how to act ..

Analog input pins are (A0, A1 & A2) Digital input pins are (D32 & D34) LED pins are (D11 for the multiplexer and D12 for the logo in the device

Please help me finish this project and I'm ready to even pay for the code :smiley:
I need a code that makes this whole device works and get recognized by the pc as a midi controller using the normal usb cable not a midi cable ..
I'm not that much into coding and programming I design equipment and manufacture them only
Thanks In Advance.

This should get you started.

There's a good reason for that:

This is not possible using the board you have, it has a single-purpose USB-to-Serial chip, the CH340G. If you want native MIDI over USB, you need to get a board that supports it, see Control Surface: MIDI over USB.

1 Like

I saw people use serial inputs as midi controllers ..
Can I use a software to translate from serial to midi ??

Any microcontroller with native USB support and at least one UART will do. You can get commercial USB-to-MIDI interfaces but they tend to be quite expensive for what they are, especially if you don't need the isolation they provide.

1 Like

Thanks a lot you've been more than helpful to me :pray:
I will start learning coding now and create a new code for the chip and reassign pins

Mr. Pieter I've started to program the device now and programmed the 48 potentiometers with no errors in the code ..
now I have 16 buttons with 16 LEDs for a 16 Steps sequencer
How can I program them to make the LEDs and buttons acting like Ableton Push pads ???
moving endlessly from step 1 to 16 and when I press a button it keeps the led on etc.
and when I press a button of an instrument I can see the recorded sequence on it and be able to change it and so on

Do not post screen images of code. Copy and paste the code itself, the complete code, into your post between code tags (the </> icon). Before you post the code, please click Tools-->Auto Format to make it easier to read.

I'm not trying to post a code I'm just showing the man my assigned pins in order to be easier for him to understand what I'm trying to do :joy::joy:

My advice stands.

1 Like

I'm not familiar with Ableton Push pads.

This is meaningless, please see the examples, don't use #define, it has no use here.

As requested by PaulRB and the forum rules, please post your code as text between code tags (</>), never post pictures of text.

2 Likes

Ok Sorry about that I got your point ..
the code :smiley:

// Include the library
#include <Control_Surface.h>
#include <MIDI_Outputs/CCButton.hpp>

// Instantiate multiplexers
CD74HC4067 M1 = { A0, {2, 3, 4, 5} }; //Analog Input
CD74HC4067 M2 = { A1, {2, 3, 4, 5} }; //Analog Input
CD74HC4067 M3 = { A2, {2, 3, 4, 5} }; //Analog Input
CD74HC4067 M4 = { 32, {2, 3, 4, 5} }; //Digital Input (Sequencer)
CD74HC4067 M5 = { 34, {2, 3, 4, 5} }; //Digital Input (Banks & Instruments)
CD74HC4067 M6 = { 11, {2, 3, 4, 5} }; //Digital Output (Sequencer)

//CCPotentiometer potentiometer = { A1, {MIDI_CC::Channel_Volume, CHANNEL_1} }; // single pot
//CCPotentiometer potentiometer = { A1, {7, CHANNEL_1} };
//CCPotentiometer pot = {pin, address}; //multiple pots
//*****Potentiometers array**************
//CCPotentiometer pots[] = { {pin, address}, {pin, address}, ... };
 
CCPotentiometer Potentiometers[] = {
    { M1.pin(0), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M1.pin(1), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M1.pin(2), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M1.pin(3), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M1.pin(4), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M1.pin(5), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M1.pin(6), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M1.pin(7), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },
    { M1.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M1.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M1.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M1.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M1.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M1.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M1.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M1.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },

    { M2.pin(0), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M2.pin(1), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M2.pin(2), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M2.pin(3), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M2.pin(4), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M2.pin(5), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M2.pin(6), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M2.pin(7), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },
    { M2.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M2.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M2.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M2.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M2.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M2.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M2.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M2.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },

    { M3.pin(0), {MIDI_CC::Channel_Volume, CHANNEL_9} },
    { M3.pin(1), {MIDI_CC::Channel_Volume, CHANNEL_10} },
    { M3.pin(2), {MIDI_CC::Effect_Control_1, CHANNEL_9} },  
    { M3.pin(3), {MIDI_CC::Effect_Control_2, CHANNEL_10} },
    { M3.pin(4), {MIDI_CC::Effect_Control_1, CHANNEL_9} },
    { M3.pin(5), {MIDI_CC::Effect_Control_2, CHANNEL_10} },
    { M3.pin(6), {MIDI_CC::Effect_Control_1, CHANNEL_9} },
    { M3.pin(7), {MIDI_CC::Effect_Control_2, CHANNEL_10} },
    { M3.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_11} },
    { M3.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_11} },
    { M3.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_11} },
    { M3.pin(11), {MIDI_CC::Foot_Controller, CHANNEL_11} },
    { M3.pin(12), {MIDI_CC::Foot_Controller, CHANNEL_11} },
    { M3.pin(13), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_11} },
    { M3.pin(14), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_11} },
    { M3.pin(15), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_11} },
};

// Initialize the Control Surface
void setup() {
  Control_Surface.begin();
}
 
// Update the Control Surface
void loop() {
  Control_Surface.loop();
}

this is for all analog inputs I have

And I changed the chip to Arduino MEGA that has UART
Now I need help with the code of the sequencer buttons and LEDs
and this is a video about Ableton Push pads

I thought it was possible using the "Hairless" software, which emulates a midi device on the PC and translates the messages to serial over USB. OK, that's not native midi-over-usb, but it does make what @medomediaproductions wants possible, doesn't it?

Why is a UART needed?

@PieterP I am not trying to challenge your advice. I'm not an expert in midi, but I am curious!

For that you need an Arduino with Native USB. No code changes on your Mega 2560 Pro can fix that, its a hardware problem.

You forgot to add a MIDI interface, see Control Surface: MIDI Interfaces.

Indeed, but like you said, it's not native MIDI over USB and the PC won't recognize the Arduino as a MIDI device.

The Control Surface: MIDI over USB link I posted earlier explains how to use Hairless with the library, basically, you just instantiate a HairlessMIDI_Interface and it should work with the default settings of Hairless.

HairlessMIDI_Interface midi;
1 Like

I think I mis-read @medomediaproductions' original post and because of that, @PieterP's responses did not make sense to me! They do now.

1 Like

you told me that it's meaningless before that's why I removed it and I have no errors in the code

I will add it again without the word "#define" ...
according to the LEDs and Buttons of the sequencer .. what I'm gonna do now ? :joy:
I'm lost in digital inputs and outputs and the internet is full of ways to program and I don't know which one is the correct one for me

The #define was useless, not the declaration of a MIDI interface.

You'll need some experience, which you get from reading a book or following a course about programming in C++, and by doing simple practice problems and projects. Writing a sequencer from scratch is not something I would recommend as a first project.

1 Like

Ok Got It ..

I will start doing this and see how it goes If I could make it

and about the already defined analog inputs If I uploaded the code to the chip will I be able to add digital I/O after and adjust the code or it's just one time coding ?

I tried to upload the sketch to the chip and it didn't work I don't know why ..
I got this error message
Arduino: 1.8.15 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

avrdude: stk500v2_command(): unknown status 0x01

avrdude: stk500v2_disable(): failed to leave programming mode

I'm lost now but with some knowledge :joy::joy::joy:

This is unrelated to the code, it has to do with the board you're using, which looks like a Chinese clone. Go through the documentation of the seller on how to program it. If it really is an ATmega2560, you might be able to flash an official Arduino bootloader to it. Either way, you should probably open a new topic for this stk500v2 error, as it's unrelated to MIDI (and your board is not an Arduino MEGA). Please use code tags to post long error messages.

1 Like

I discovered that it's a Chinese clone and did the needed steps for the code uploading and everything was fine ... but the device doesn't stop sending messages to the Hairless midi software
7
I tried to map the device to any analog input in the DAW and it didn't work
I used everything you told me about
here's the used code

#include <Control_Surface.h>
USBMIDI_Interface midi;

CD74HC4067 M1 = { A0, {2, 3, 4, 5} }; //Analog Input
CD74HC4067 M2 = { A1, {2, 3, 4, 5} }; //Analog Input
CD74HC4067 M3 = { A2, {2, 3, 4, 5} }; //Analog Input


CCPotentiometer Potentiometers[] = {
    { M1.pin(0), {MIDI_CC::Channel_Volume, CHANNEL_1} },
    { M1.pin(1), {MIDI_CC::Channel_Volume, CHANNEL_2} },
    { M1.pin(2), {MIDI_CC::Channel_Volume, CHANNEL_3} },
    { M1.pin(3), {MIDI_CC::Channel_Volume, CHANNEL_4} },
    { M1.pin(4), {MIDI_CC::Channel_Volume, CHANNEL_5} },
    { M1.pin(5), {MIDI_CC::Channel_Volume, CHANNEL_6} },
    { M1.pin(6), {MIDI_CC::Channel_Volume, CHANNEL_7} },
    { M1.pin(7), {MIDI_CC::Channel_Volume, CHANNEL_8} },
    { M1.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M1.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M1.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M1.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M1.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M1.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M1.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M1.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },

    { M2.pin(0), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M2.pin(1), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M2.pin(2), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M2.pin(3), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M2.pin(4), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M2.pin(5), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M2.pin(6), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M2.pin(7), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },
    { M2.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} },
    { M2.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M2.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M2.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M2.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M2.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M2.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} },
    { M2.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_8} },

    { M3.pin(0), {MIDI_CC::Channel_Volume, CHANNEL_9} },
    { M3.pin(1), {MIDI_CC::Channel_Volume, CHANNEL_10} },
    { M3.pin(2), {MIDI_CC::Effect_Control_1, CHANNEL_9} },  
    { M3.pin(3), {MIDI_CC::Effect_Control_2, CHANNEL_10} },
    { M3.pin(4), {MIDI_CC::Effect_Control_1, CHANNEL_9} },
    { M3.pin(5), {MIDI_CC::Effect_Control_2, CHANNEL_10} },
    { M3.pin(6), {MIDI_CC::Effect_Control_1, CHANNEL_9} },
    { M3.pin(7), {MIDI_CC::Effect_Control_2, CHANNEL_10} },
    { M3.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_11} },
    { M3.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_11} },
    { M3.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_11} },
    { M3.pin(11), {MIDI_CC::Foot_Controller, CHANNEL_11} },
    { M3.pin(12), {MIDI_CC::Foot_Controller, CHANNEL_11} },
    { M3.pin(13), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_11} },
    { M3.pin(14), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_11} },
    { M3.pin(15), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_11} },
};


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

}

void loop() {
  // put your main code here, to run repeatedly:
  Control_Surface.loop();

}