[Solved]Wireless Midi Control

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.


int potPin = 0;

void setup()

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

   Serial.print(midiCtrl, DEC);



void loop () {

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

  if(Serial.available() > 0)
  note = Serial.read();


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.


I don't think you want to do this:

Serial.print(midiCtrl, DEC);

I think you want this:

Serial.print(midiCtrl, BYTE);

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

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.