Hello everyone,
I have a project in Arduino in which I have to send the MPU pitch and roll data to Matlab through serial communication.
The issue that I have is that Matlab does not read negative values, I ve tried changing my code in Arduino but still didn t work.
Arduino:
void GyroPacket(int p,int r,int t, int tempp){
Serial.write(250);
Serial.write(4);
Serial.write(0);
Serial.write(15);
Serial.write(1);
Serial.write(highByte(p)); // Transmit high byte of pitch
Serial.write(lowByte(p)); // Transmit low byte of pitch
Serial.write(highByte(r)); // Transmit high byte of roll
Serial.write(lowByte(r)); // Transmit low byte of roll
// Serial.write(p);
// Serial.write(r);
Serial.write(t);
Serial.write(tempp);
}
Could anyone guide me?
That explanation helps. The Mega has several serial ports. "Serial" is the one used for downloading code as well as printing to the serial monitor in the IDE.
Use the Serial1 for COM equipment.
You need to have communications between Matlab and the Arduino working correctly, and the received data properly interpreted, before any measurements can be made.
Assuming the above code converts two unsigned bytes to a 16 bit signed integer correctly, where are you displaying those converted values? The only bit of code I saw that appeared to be displaying anything was displaying the unconverted unsigned bytes.