help with wireless midi via Xbees

Status
Not open for further replies.

Balam

Active member
Hi,
been working on my first teensy project ( big thanks to all of you in the forum )
My idea is to use 2 teensys + 2 xbees and send data as serialprint from project to the second teensy xbee combo that will translate the serial.print info into Usb midi and do magic from there.

the question is how can the second teensy read ( serial string ) or if you have a better idea of how to do serial read of several Strings ( sensors data comming from project )

please see my attach image and attempt of code

thanks in advance

tensyxbee_bb.jpg

code for teensy reading sensor and sending sensor data

Code:
#include <SoftwareSerial.h>

#include <Bounce.h>  // Bounce library makes button change detection easy
const int channel = 1;

 Bounce button2 = Bounce(2, 5);  // 5 = 5 ms debounce time


HardwareSerial Uart = HardwareSerial();

void setup() {
  Serial.begin(57600);
   pinMode(2, INPUT_PULLUP);
}

void loop() {


  button2.update();


  
 

//btn///


if (button2.fallingEdge()) {
    usbMIDI.sendNoteOn(61, 99, channel);  // 61 = C#4
    Serial.println(B2-1);
    
  }


if (button2.risingEdge()) {
    usbMIDI.sendNoteOff(61, 0, channel);  // 61 = C#4
    Serial.println(B2-0);
  }

  
  
///////

// MIDI Controllers should discard incoming MIDI messages.
  while (usbMIDI.read()) {
  }



  ///clean the buffer

  Serial.flush();
}





code for reciever


Code:
// coonected to computer USB_______Usb----computer


#include <SoftwareSerial.h>



const int channel = 1;


 

HardwareSerial Uart = HardwareSerial();




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

void loop() {


  
  if(Serial.available() ) {
    incomingByte1 = Serial.read();  // will not be -1
    // actually do something with incomingByte
    


    
  }
}
 
Status
Not open for further replies.
Back
Top