Hello
I'm doing a project where I have to send a few variables as serial data from a stm 32 microcontroller to an arduino. To figure out how to do this, I'm sending a few words between characters that should be used as separators. But the arduino isn't printing what should be.
Here's the code that's on stm32
char record[] = "print:two&words";
void setup() {
Serial1.begin(57600);
}
void loop() {
Serial1.write(record);
Serial1.println();
delay(1000);
}
and the code on arduino
void setup()
{
Serial.begin(57600);
}
void loop() {
if (Serial.available()) {
int var;
var = Serial.read();
char *token = strtok(var, ":");
Serial.write(token);
delay(200);
}
}
What I want to print is the original sentence until the separator character, in this case it should print the word "print" only. When this works, I need to print the word between : and &, and so on. Will you please help me?
this is what this code is printing
rnt:twwrs
rnt:twwrs
rnt:twwrs
rnt:tw&wr
rnt:tw&wrsrntrn:rrntrntrnwnrnrn&rnrnrnrn
rn
rnrntrntrnt