So I am trying to get my arduino uno to talk to my arduino due but I'm having issues getting the data outputted on the due side. My arduino uno is the master while the due is the slave. The sensor is connected to the uno and I just require the arduino due to receive and spit out the data as it has a faster sampling rate than the arduino uno. I connected them along the serial (Tx and Rx) lines. And I'm using Serial3 on my arduino due to receive the transmitted data. Both arduinos are grounded together. But powered differently by usb cables connected to my machine. On the arduino uno end ( for brevity sake) the data is sent in binary with the $ sign as the starter bit. Here is the code for the receiving end ( the slave). I just can't seem to get the data out on the serial monitor.
byte b = '$';
unsigned char buffer[12];
int count =0;
void setup() {
Serial.begin(115200);
Serial3.begin(115200);
delay(5);
}
void loop() {
if(Serial.available())
{
if (b == Serial.available())
{
while(Serial.available())
{
buffer[count++] = Serial.read();
if(count == 12)break;
//Send the byte to serial port three
Serial3.write(buffer, count);
}
}
if (Serial3.available()){
//get a byte from serial port 3
if(b == Serial3.available()){
buffer[count++] = Serial3.read();
//Send the byte to the USB serial port
Serial.write(buffer, count);
}
}
Serial.println("lyca");
}
}