Hello everyone,
We got stuck receiving wrong data from Processing on our Arduino Uno. We only need 4 different values to control the system. It works the other way though: Getting data from Arduino to Processing has not been a problem. We got data straight away after sending a command in processing, but only random numbers so far. Strangely the width was never greater than 8 bits, e.g. it seems to read exactly one byte from the buffer.
Baud rate is 9600 and we also avoided using Serial.print() to troubleshoot at one point as we thought it might interfere with the transmission. In the setup routine we import the library SoftwareSerial.h.
What we have tried so far:
-Using bytes, chars, ints and String on both ends.
-Using Serial.parseInt() instead of Serial.read() to get the data from the buffer
void getBluetooth() {
if (Serial.available() >= MESSAGE_BYTES)
{
//if (Serial.read() == HEADER) {
int receivedmsg = (Serial.read()); //programm
Serial.print("received: ");
Serial.println(receivedmsg);
if (decryptmsg(receivedmsg) != -1) {
programm = decryptmsg(receivedmsg);
//achtung Serial.prints() auskommentieren für eigentliche Anwendung, schreibt sonst auf BT
Serial.println("succesful msg ->" + programm);
} else {
Serial.println("failed msg!");
// }
}
}
}