Pages: [1]   Go Down
Author Topic: MIDI Modulation from expression pedal  (Read 2262 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm a MIDI guitarist, and as such I don't have one thing that all keyboardists have: a modulation wheel.  I have started a project to build a modulation wheel into an expression pedal.  The expression pedal itself is nothing more than a potentiometer, which I have wired to an analog input on my Arduino.  I have successfully written code which outputs MIDI notes depending on the position of the expression pedal, but when I modify that very same code to output modulation instead, it either doesn't work or it changes my sound module's patch.

Here's my current code.  What you need to know is that the sound module is set to MIDI channel 1.  Anyone see something I've missed?

const int expressionPin = 1;
const int controlCmd = 0xB1;
const int modulationCmd = 0x01;
int expressionVal = 0;
int oldVal = 0;
int newVal = 0;

void setup() {
  Serial.begin(31250);  //MIDI Baud Rate

}
void loop() {
  expressionVal = analogRead(expressionPin);
  newVal = map(expressionVal, 0, 1023, 0x00, 0x5F);
  if (newVal != oldVal)
  {
    writeModulation(newVal);
    oldVal = newVal;
  }
}

void writeModulation(int val)
{
  Serial.print(controlCmd, BYTE);
  Serial.print(modulationCmd, BYTE);
  Serial.print(val, BYTE);
}
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't you want to send 0xB0 for channel 1 instead of 0xB1?

If the code works (and it looks like it should) for sending out note data, then I'm afraid it's the receiver that is misinterpreting something. Is it possible you're sending new values just a little too fast? Try putting in a delay in your loop for just a few milliseconds.

--
Beat707: MIDI drum machine / sequencer / groove-box for Arduino
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK so it's working now.  If, by any chance, any of you own a Parker MIDI Fly, a word of caution: changing the position of the MIDI mode or MIDI octave switches on your instrument resets the modulation value to zero - and on a Moog Slim Phatty, this means having to re-twist the knob to reflect the maximum modulation you want.

Thanks for your help, RuggedCircuits!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'v created a homemade synth using arduino and a couple rotary pots, I then send the data to a real midi controller which is connected to a software syth program on my laptop. I can play notes though the contraption, and I can use the pitch wheel, but I can't get the mod wheel to work? Do you guys have any suggestions or examples of how to do more then just play notes and pitchwheel?

I'm not using the midi library, I'm just writing out the code by hand.
Logged

Pages: [1]   Go Up
Jump to: