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=202I'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/ArduinoXbeeShieldI'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:
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:
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