Arduino MIDI Light controller

Ok so as it stands I don't even know how to start. I want to make a light controller that will take a signal for the computer MIDI software and use that signal to control lights. I'm using arduino leaonardo so MIDIUSB library should allow me to connect using usb cable. I've only done some very simple programs before so please explain as if I was 9.

Thanks, and sorry for the complete lack of any code :frowning:

Edit: Just an example or a point in a right direction would be helpful, I just have no idea how to recive the data and from there I should manage.

You didn't give much information.
What kind of lights do you want to control? What software do you plan on using? Does it use regular MIDI or MIDI Show Control?
Can you control the lights without MIDI? What's wrong with the examples you can find online? Did you try any of them?

Pieter

Just any MIDI like garage band etc, if I'm not mistaken programs like that can send out data like (chanel, note, velocity). I'd like to use that data to then send signals to MOSFETS/Relays to turn the lighs in time with the music. only tutorials I've seen use arduino to send data rather than receive it.

Something like this?

https://tttapa.github.io/Control-Surface/Doc/Doxygen/dd/dcc/md_Getting-Started.html#first-input

Yes, but using MIDI from a computer directly so that the lights show can be programed. I'll look over the code and try to compile something, but I've never done anything this complicated I'm a complete newbie when it comes to programing. Thanks.

Edit: To do what I want I might need to use MIDIUSB library isntead, sorry I know I'm being difficult.

The MIDI is coming from the computer. The keyboard is connected to the computer over USB, then the MIDI from the keyboard is routed to the Arduino over USB by software on the computer.

If you use the USBMIDI_Interface, the Arduino shows up as a MIDI device when you plug it into your computer.

Adi94:
Edit: To do what I want I might need to use MIDIUSB library isntead, sorry I know I'm being difficult.

The link I posted earlier uses the MIDIUSB library under the hood (on the Leonardo and some other Arduino boards that support it).

USBMIDI_Interface is an abstraction layer on top of the underlying platform-specific MIDI library (e.g. MIDIUSB) that provides higher level functions to send, receive and parse MIDI events.

Ok, so I went through it and i get a whole buch of these messeges

"

C:\Users\Yandere Chan\Documents\Arduino\libraries\Control-Surface-master\src/MIDI_Outputs/Bankable/Abstract/MIDIFilteredAnalog.hpp: In instantiation of 'Bankable::MIDIFilteredAnalog<Sender, PRECISION>::MIDIFilteredAnalog(const OutputBankConfig&, pin_t, const MIDICNChannel&, const Sender&) [with Sender = PitchBendSender<10u>; unsigned char PRECISION = 10u; pin_t = unsigned int]':

C:\Users\Yandere Chan\Documents\Arduino\libraries\Control-Surface-master\src/MIDI_Outputs/Bankable/PBPotentiometer.hpp:37:62: required from here

C:\Users\Yandere Chan\Documents\Arduino\libraries\Control-Surface-master\src/MIDI_Outputs/Bankable/Abstract/MIDIFilteredAnalog.hpp:107:69: error: too many initializers for 'PitchBendSender<10u>'

filteredAnalog{analogPin}, address{address}, sender{sender} {}

^

exit status 1
Error compiling for board Arduino Leonardo.

"
could I have just gotten a wrong library?

Could you post your code? What version of the IDE and the library are you using?

here is the code, and I got the library from GitHub - tttapa/Control-Surface: Arduino library for creating MIDI controllers and other MIDI devices.

// Include the library
#include <Control_Surface.h>
 
// Instantiate a MIDI Interface to use
USBMIDI_Interface midi;
 
// Instantiate a shift register as output for the LEDs
SPIShiftRegisterOut<8> sreg = {
  10,       // Latch pin (ST_CP)
  MSBFIRST, // Byte order
};
 
using namespace MIDI_Notes;
 
// Create an array of LEDs that listen to MIDI Note messages, turning on and off
// the LEDs connected to the eight input pins of the shift register
MIDINoteLED leds[] = {
  {sreg.pin(0), note(C, 4)}, // LED pin, address (note number, channel, cable)
  {sreg.pin(1), note(D, 4)}, //
  {sreg.pin(2), note(E, 4)}, //
  {sreg.pin(3), note(F, 4)}, //
  {sreg.pin(4), note(G, 4)}, //
  {sreg.pin(5), note(A, 4)}, //
  {sreg.pin(6), note(B, 4)}, //
  {sreg.pin(7), note(C, 5)}, //
};
 
// Initialize the Control Surface
void setup() {
  Control_Surface.begin();
}
 
// Update the Control Surface
void loop() {
  Control_Surface.loop();
}

I'll look into it, it compiles just fine for me.

Could you post the entire error message? The actual error is probably somewhere else.

I updated arduino IDE and it compiled fine, there might be an issue with 1.8.4 and lower works just fine with 1.8.10, now i have to figure out how to make leds come on xD just need to figure out sreg.pin() or get digitalWrite to make it work. Thanks a lot and sorry for any trouble it's a neat library :slight_smile:

Glad to hear that you got it to work!

If you want to use the normal Arduino pins, you can just use those pin numbers instead of "sreg.pin(n)":

For example, if you have your LEDs connected to pins 0-7:

// Include the library
#include <Control_Surface.h>
 
// Instantiate a MIDI Interface to use
USBMIDI_Interface midi;
 
using namespace MIDI_Notes;
 
// Create an array of LEDs that listen to MIDI Note messages, turning on and off
// the LEDs connected to the eight input pins of the shift register
MIDINoteLED leds[] = {
  {0, note(C, 4)}, // LED pin, address (note number, channel, cable)
  {1, note(D, 4)}, //
  {2, note(E, 4)}, //
  {3, note(F, 4)}, //
  {4, note(G, 4)}, //
  {5, note(A, 4)}, //
  {6, note(B, 4)}, //
  {7, note(C, 5)}, //
};
 
// Initialize the Control Surface
void setup() {
  Control_Surface.begin();
}
 
// Update the Control Surface
void loop() {
  Control_Surface.loop();
}

OMG Thank you so much :slight_smile: if im not mistaken youre the author of the library? anyway thank you so much I'll have a read throu it and try to play around with it :slight_smile: this really needs to be promoted more :slight_smile:

Adi94:
if im not mistaken youre the author of the library?

You are not mistaken :slight_smile:

It's great to hear you find it useful!

also is there a way to use it with individualy adressable led strips? control the brightess ? sorry :slight_smile: ill look throug the documentation on it :slight_smile:

I have experimented with WS2812b LED strips, but they have some serious problems that cause loss of MIDI data on boards like the Arduino UNO and Mega:

The USB buffer of the Leonardo may be large enough, but I don't really know.

I'll try to add the code tonight.

DISCLAIMER - I've never used MIDI or DMX.

also is there a way to use it with individualy adressable led strips? control the brightess ?

Yeah... The timing is critical for WS2812/NeoPixels,and of course MIDI has timing requirements too, and you only have one processor to do everything. DotStars are not so critical, but you still might get some interruption of the lighting data.

Maybe there's a way to use 2 Arduinos??? (It still takes "CPU cycles" to communicate between the two, but you might be able to more-easily control the timing.)


...Just in case you don't already know this, there is a stage/theatrical standard for lighting called [u]DMX512[/u]. If you are doing any kind of "big" stage production you may already have DMX lighting, or that's what you'd likely be using.

DMX is entirely different from MIDI, but you can build (or buy) a MIDI-to-DMX converter. But even if you buy one, it has to be custom programmed because you need to define how each MIDI instruction is converted to whatever DMX instruction you want for your particular application.

Of course, if you are using regular LEDs or directly-controlling "standard" lights, the extra steps and extra hardware of MIDI-to-DMX, and then building DMX decoder to control the lights are not worth it.

I've done a couple of sound-activated lighting effects, and I just made "direct connections" (via solid state relays, etc.). I have an "idea" for a custom-programmable sound-activated DMX controller, but that hasn't got past the "idea" stage and I don't have the DMX lights yet.

Seems like I'll be runing arduino cluster hahaha for I'll just try to figure some more things like dimming lights by changing volium or velocity, my high power LEDs wont arivie till mid october anyway. Once again thanks a lot :slight_smile: I tried it with just little 3.5mm LEDs and it works beautifully.

Also for anyone coming here with the same issue I had, update arduino IDE and the code is down below its basicly plug and play. All credit goes to PieterP :slight_smile:

// Include the library
#include <Control_Surface.h>
 
// Instantiate a MIDI Interface to use
USBMIDI_Interface midi;
 
// Instantiate a shift register as output for the LEDs
SPIShiftRegisterOut<8> sreg = {
  10,       // Latch pin (ST_CP)
  MSBFIRST, // Byte order
};
 
using namespace MIDI_Notes;
 
// Create an array of LEDs that listen to MIDI Note messages, turning on and off
// the LEDs connected to the eight input pins of the shift register
MIDINoteLED leds[] = {
  {0, note(C, 4)}, // LED pin, address (note number, channel, cable)
  {1, note(D, 4)}, //
  {2, note(E, 4)}, //
  {3, note(F, 4)}, //
  {4, note(G, 4)}, //
  {5, note(A, 4)}, //
  {6, note(B, 4)}, //
  {7, note(C, 5)}, //
};

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