Hi friends, I am developing a midi wireless communication project using 2 one arduinos, 2 xbee sheld and two xbee s2c transmitters, in the process, I made the xbees peer configuration via xctu software, tested the communication and was successfully performed, they talk to each other! however, when I connect xbees to shield and arduino communication just doesn't happen, I wonder if they could help me with solving this problem! (I already did the arduino communication tests without xbees and it was also successful!) follow the codes used!
Transmitter Code
#include
#include
uint8_t ssRX = 10;
uint8_t ssTX = 11;
// set up a new serial object
SoftwareSerial mySerial (ssRX, ssTX);
byte in_buffer[1024]; //maximum number of bytes arrived in one cpu cycle
unsigned int received_bytes;
void setup(){
Serial.begin (9600); //XBEE transmission
mySerial.begin(31250); //CABO MIDI transmission
received_bytes=0;
while (!Serial) {
; // Espera a porta serial conectar. Necessário para USB nativa
}
}
void loop(){
if(mySerial.available() > 0)
{
received_bytes=mySerial.available();
for (int i=0;i
Receptor Code
#include
#include
uint8_t ssRX = 10;
// Connect Arduino pin 9 to RX of usb-serial device
uint8_t ssTX = 11;
// set up a new serial object
SoftwareSerial mySerial (ssRX, ssTX);
void setup(){
Serial.begin (9600); //XBEE transmission
mySerial.begin(31250);//CABO MIDI transmission
//led 13 used for debug
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}
void loop(){
if(mySerial.available() > 0){
digitalWrite(13, HIGH);
Serial.write(mySerial.read()); //receives the midi messages via XBEE...and send it to Synth
digitalWrite(13, LOW);
}
if (Serial.available()) {
digitalWrite(13, HIGH);
mySerial.write(Serial.read());
digitalWrite(13, LOW);
}
//Test function
//SendAllNotes();
}
////////////////////////////////////////////////////////////////////////////////////////////
//
// MIDI HELPER FUNCTIONS (taken from http://arduino.cc/en/Tutorial/Midi?from=Tutorial.MIDI)
//
////////////////////////////////////////////////////////////////////////////////////////////
void SendAllNotes() {
// play notes from F#-0 (0x1E) to F#-5 (0x5A):
for (int note = 0x1E; note < 0x5A; note ++) {
//Note on channel 13 (0x9C), some note value (note), middle velocity (0x45):
digitalWrite(13, HIGH);
MIDICommand(0x9C, note, 0x45);
delay(100);
digitalWrite(13, LOW);
//Note on channel 13 (0x9C), some note value (note), silent velocity (0x00):
MIDICommand(0x9C, note, 0x00);
delay(100);
}
}
// Send a midi command. Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:
void MIDICommand(int cmd, int pitch, int velocity) {
Serial.write(cmd);
Serial.write(pitch);
Serial.write(velocity);
}