Go Down

Topic: Simple Midi cc send with a botten ?? Help. (Read 1 time) previous topic - next topic

guitarans

Hi im new in this! very new. :smiley-eek:
Ive viewed looked at many sketches from the internet, many of them are overwhelming and too much anve very impressing..
I also tryed to look at the Midi reference, but i just can figure out how to put the sketch together.

all the midi is a riddle for me!!

What i would like to do is, press a botton and send a midi cc "command"

im with so far:

int buttonPin = 2;

void setup() {
   Serial.begin(31250);
}
void loop ()
if (buttonState == HIGH) {     

Serial.Write

----------------
and thats it, i know that this not is rocket science, but im finding it hard to understand.

the history behind this is that i would like a extra botten to control my guitar pedal ( a Boss GT-10 ) and within the i pedal i can activate "like an fx" if it reciewe a midi cc ( called CC#1 to 31 or 64 to 95 )

so if i can make the a botton send a midi cc command when pressed it would be great..

 

guitarans

is this it??? exept the baud rate?

void setup() {
Serial.begin(57600); // open serial port
}

void loop() {

Serial.print(0xB2, BYTE); // MIDI control change; channel 3
Serial.print(1, BYTE); // MIDI controller #1
Serial.print(127, BYTE); // MIDI controller value of 127

}

marco_c

You don't want to send the CC message every time you detect the input to be high, so you need to only do this when you detect the switch gong from inactive state to active state (called "edge detection").

The last code you supplied does not use a switch at all?

Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

guitarans

Thats right.

Just before i went to bed i found the cc code, i think?

But yes.  When the botten is pressed i would like to send the midi data. And it well send again when i press the botten again.

guitarans

:smiley-mr-green:

UHU!!! I got some life ( or communication )  or, this is a BIG step for me !!!!

i tryed this code, and are now avaible to use a pot to send the midi cc


byte val = 0;

void setup() {
Serial.begin(31250);
}

void loop() {
val = analogRead(0) / 8;

Serial.print(0xB0, BYTE); // MIDI control change; channel 1
Serial.print(1, BYTE); //    CC#1
Serial.print(val, BYTE); // MIDI controller value from potentiometer 1
delay(5);
}

but, i  still need to get my botton to work with it ? du i change the val to a number ? and why does the sketch starts with " byte val = 0 " ??

marco_c

Wrap the code to send the MIDI message in an if statement

if button is pressed
{
  send midi message
}

Clearly you will need to write actual code, but that is the basic logic. If you are comfortable writing a function that returns true or false if the button edge has been detected, it is neater to wrap up the code in that sort of construct. Otherwise just write it inline in loop().
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Grumpy_Mike

That code will not even compile using the latest Arduino IDE replace
Code: [Select]

Serial.print(0xB0, BYTE); // MIDI control change; channel 1
with
Serial.write(0xB0); // MIDI control change; channel 1

The same for the other two print statements.

Real the how to use the forum sticky to find out how to post code.
Look at the examples menu in the IDE for the basics of programming, they are simple examples.

guitarans

Oh yes, i didnt mention that im using ide version 0023, with the newer version wont eat the BYTE command

Go Up