Hi, I connect 2 teensy 3.5 to make an spectrum analyzer. An audio board is connected to a master Teensy. I sent 4 bands of FFT to the slave Teensy using Serial TX pin 1. Since the data is in float, i converted it to int and parse it into a string and ended it with \n so that at the slave side I can detect an newline and split the data. However I noticed Teensy will stuck after sometimes. The slave data will be used to control the led array, somehow if i remove the led function, slave teensy will not stuck.
Master to Slave
Code:
//serial from master
if (Serial1.available()) {
// Serial.println(".");
if (Serial1.read() == '\n') {
int_1 = Serial1.parseInt();
int_2 = Serial1.parseInt();
int_3 = Serial1.parseInt();
int_4 = Serial1.parseInt();
}
}
Master to Slave
Code:
//convert float to int for slave
// Serial.println();
int1 = 1000 * myFFT.read(47, 93); //2k to 4k
int2 = 1000 * myFFT.read(94, 186); //4k to 8k
int3 = 1000 * myFFT.read(187, 255); //8k to 11k
int4 = 1000 * myFFT.read(256, 511); //11k to 22k
//send to slave
if (currentMillis - previousMillis_2 > 10) {
// save the last time you blinked the LED
previousMillis_2 = currentMillis;
// Serial.print(int1);
Serial1.print(int1); Serial1.print(",");
Serial1.print(int2); Serial1.print(",");
Serial1.print(int3); Serial1.print(",");
Serial1.print(int4); Serial1.print('\n');
}