Pages: [1]   Go Down
Author Topic: [Solved]Wireless Midi Control  (Read 729 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
 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
« Last Edit: April 08, 2011, 05:02:04 pm by neo_nmik » Logged

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

I don't think you want to do this:

Code:
Serial.print(midiCtrl, DEC);

I think you want this:

Code:
Serial.print(midiCtrl, BYTE);

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

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

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.
Logged

Pages: [1]   Go Up
Jump to: