Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

PRO FESSIO NA L EDUCA TI O N STO RE Search on Arduino.

cc SIGN IN

Arduino Forum > Using Arduino > Audio > MIDI CONTROLLER - Turn LEDs on with MIDI messages!
HAR D WAR E

Go Down Pages: [1]


PRINT

Topic: MIDI CONTROLLER - Turn LEDs on with MIDI messages! (Read 5087 times) Previous Topic - Next Topic

soykarim MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 05:01 am
Guest

Hello everyone, this is my first post so I'm gonna introduce me


I'm Karím. I'm 14 yrs old and I'm from Argentina.
Some weeks ago, I started my first Arduino project: A MIDI Controller for DAWs and DJs software.
I've almost finished the code for buttons, encoders and potentiometers out. Now I'm in the 'MIDI LED feedback' part.
I want to get LED on when the button is pressed with a code like this:

Code: [Select]

#define boton1 51
#define boton1led 50

int keyispressed1 = 0;
int noteisplaying1 = 0;

🍪
void setup() {
Serial.begin (115200);
We use cookies pinMode(boton1, INPUT);

Our websites use cookies (also from third parties) for functional and( I took off the MIDI out part for give you a shorter code )
analytical purposes, and to show you personalised advertisement. You can
adjust this in Cookie Settings or learn more by reading our cookie But
policy.
also, if the button I pressed has a toggle function in the software (like "Play", something
that still activated after "un-
press"), I want to send a message from the software (I tried and it's possible) and somehow get the LED still on. (Sorry for
my bad english, this is very hard to explain hahaha).
ONLY REQUIRED ACCEPT ALL
The software can send:
A "note on" with velocity "127" when the function is activated, and velocity "0" when is desactivated.
Also, it can send a "Control Change" with same configuration of velocity.

I tried with reading "raw" serial and with the MIDI Library too, but I don't get it working...

Code: [Select]

byte message;
byte note;
byte velocity;
int led = 13;

void setup() {
pinMode(led,OUTPUT);
Serial.begin(115200);
digitalWrite(led,LOW);

Code: [Select]

#include <MIDI.h>

byte led = 13;


byte channel = 1;

void setup() {
pinMode(led, OUTPUT);
Serial.begin(115200);
}

PLEASE HELP ME, I can't figure how get it working!


Thank you!

Grumpy_Mike Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 05:22 am #1

Code: [Select]

if (Serial.available() > 0) {
Brattain Member
message = Serial.read();
Posts: 62,883
note = Serial.read();
velocity = Serial.read();
Karma: 2521  [add]
Solder is electric glue
http://www.thebox.myzen.c So if one byte is available to read you go ahead and read three bytes. See anything wrong in that?
o.uk

soykarim Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 06:39 am #2
Guest

Quote from: Grumpy_Mike on Sep 11, 2013, 05:22 am


Code: [Select]

if (Serial.available() > 0) {

message = Serial.read();
note = Serial.read();
velocity = Serial.read();

So if one byte is available to read you go ahead and read three bytes. See anything wrong in that?

Thank you! Now the midi in works great! That was easy hahaha

But I've a problem implementing the default "LED on while button is pressed" with the MIDI in from software.
If I activate the control from my computer, the software send the message and LED turn on. But if I press the button,
and the message comes in while LED is on by default, when I "unpress" the button the LED just turn off.
Do you understand me? How can this be solved?

This is the full code:

Code: [Select]

byte message;
byte note;
byte velocity;

int led = 13;

int boton1 = 51;

int keyispressed1 = 0;

Thank you!

soykarim Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 07:23 am #3
Guest

I need something like a buffer that store the action of 'turn on LED when the midi message arrives' until I release the
button, don't?
How can it be done?

Grumpy_Mike Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 09:04 am #4

Quote

❝ But I've a problem implementing the default "LED on while button is pressed" with the MIDI in from software.
Brattain Member If I activate the control from my computer, the software send the message and LED turn on. But if I press the button, and the message
Posts: 62,883 comes in while LED is on by default, when I "unpress" the button the LED just turn off.

Karma: 2521  [add]
Sorry but no I don't understand.
Solder is electric glue What is meant by on by default?
http://www.thebox.myzen.c How does it get into that state.
o.uk You seam to have an inconsistency in your logic. If a released button turns off an led what is the thing that turns it off
when it is on by default?

capicoso Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 06:30 pm #5

Quote from: Grumpy_Mike on Sep 11, 2013, 09:04 am


Full Member Quote
Posts: 169
Karma: 31  [add] ❝ But I've a problem implementing the default "LED on while button is pressed" with the MIDI in from software.
If I activate the control from my computer, the software send the message and LED turn on. But if I press the button, and the
message comes in while LED is on by default, when I "unpress" the button the LED just turn off.

Sorry but no I don't understand.


What is meant by on by default?
How does it get into that state.
You seam to have an inconsistency in your logic. If a released button turns off an led what is the thing that turns it off when it is on by
default?

If I understood well, when the arduino is receiving midi messages he wants a note off message to turn off the led, and not
the button.
I suppose he could use a flag so when it's receiving midi messages the button off part with  doesn't happens... I don't
understand why he's receiving midi messages from the daw. Something like this? http://www.youtube.com/watch?
v=Ztw-4VHIQaQ

soykarim Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 11, 2013, 09:33 pm #6
Guest

Look at these videos:

Here, when you press a button the LED turn on


        and when you release it LED turn off.
https://www.youtube.com/watch?v=0kbuFmOLQJo

Here, the LEDs still on although you release the button.


That's because the DJ software send a ControlChange message to the controller.
https://www.youtube.com/watch?v=TN8EbcD32CY

Software send a message like this:


176-1-127 (For turn LED on)
176-1-0 (For turn LED off)

I've working the two parts, but separately.


When I hit "Play" in software with my mice, the software send the message and the LED turn on.
If I press the button of my controller, the first thing happens (LED on while button is pressed), but as the software
message arrives while is this happening, the Arduino ignore it.

Here is a video I shoot.


http://www.youtube.com/watch?v=1taA3bD9t5E
I put anotations in it for explain a bit more.

I think I need a buffer for save the message until I release the button.

Please forgive me if I can't explain it very well, it's so hard in English for me!

soykarim Re: MIDI CONTROLLER - Turn LEDs on with MIDI messages!


Sep 12, 2013, 07:37 pm #7
Guest

I COULD SOLVE IT BY MYSELF.


ANYWAY, THANK YOU FOR HELP.

Go Up Pages: [1]
PRINT

Jump to:
=> Audio   Go

B a ck t o t o p

Tra d e m a rk Help Cen ter N EW SLET T ER FOLLOW US

C o n t a ct U s
Enter your email to sign up S UBS C RIBE
D i st ri b u t o rs

C a re e rs

© 2021 A rd u i n o Te rm s O f S e rv i ce P ri v a cy P o l i cy S e cu ri t y Co o k ie Settin gs

You might also like