Go Down

Topic: [Solved]Wireless Midi Control (Read 780 times) previous topic - next topic

neo_nmik

Apr 08, 2011, 07:23 pm Last Edit: Apr 09, 2011, 12:02 am by neo_nmik Reason: 1
I was unsure whether to put this in here, or the specific midi section. I chose this section because it's more a question about code...


Anyway! My project is based on this... http://blog.jpcarrascal.com/?p=202

I'm aiming to use a couple of potentiometers and an accelerometer to control MIDI and a PWM output to simulate an expression pedal.

I have a 5v Pro Mini attached to an Xbee, using a regulated explorer shield, which are linked, via another Xbee (using the xbee shield from Libelium) connected through a Sparkfun MIDI Shield to a Uno.

(A lot of info here, but it's better than asking and answering questions on information I could easily provide)

I know the xbee's are connecting as I used the Physical Pixel example:  http://arduino.cc/en/Guide/ArduinoXbeeShield

I'm just majorly struggling on how to get the potentiometers output over the serial, take what comes over the serial, and use the variable to control the midi control data.

Transmitter:
Code: [Select]
int potPin = 0;

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

void loop()
{
  int potVal = analogRead(potPin);
  int midiCtrl = map(potVal, 0, 1023, 0, 127);

  Serial.print(midiCtrl, DEC);
  delay(100);
}


Receiver:
Code: [Select]
 Serial.begin(31250);    
}

void loop () {

 //*************** MIDI OUT ***************//


 if(Serial.available() > 0)
 {
 note = Serial.read();
 
   Midi_Send(0xB0,0x01,note);
 }

}

void Midi_Send(byte cmd, byte data1, byte data2) {
 Serial.print(cmd, BYTE);
 Serial.print(data1, BYTE);
 Serial.print(data2, BYTE);
}


I've got a feeling the receivers code is wrong, but I have NO idea how... I've searched high and low to no avail...

Thanks for reading, and if you can help, you're a star.

Nick

RuggedCircuits

I don't think you want to do this:

Code: [Select]
Serial.print(midiCtrl, DEC);

I think you want this:

Code: [Select]
Serial.print(midiCtrl, BYTE);

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

neo_nmik

You were right!

It also turned out the MIDI shield needed to be set to program, instead of run so the Xbee could use the serial input.


Thanks very much.

Go Up