On bluetooth from one arduino to another a string is transmitted. The second Arduinka accepts this string byte-by-byte and sends the port to the serial as well. It turns out one or two characters on the line. How to fully assemble a string in order to further perform some actions with it? In the passed string, did end-of-line pointers, in this case left "\n" . I tried this option, but at the output I get all the same some kind of nonsense and not always my “flag” is noticed, it seems to trigger on it, but sometimes it slips into the port monitor when I watch

 char buffer[100]; int i; for(i=0;i<100;i++) { buffer[i]=Serial.Read(); Serial.flush(); if(buffer[i]=='\n') break; } 
  • Serial.flush() is almost certainly superfluous ... if Serial.Read() reads one byte from the bluetooth uart, then otherwise everything is fine ... from the common rake, I can assume that after the cycle into the line the final zero is not added ... - Fat-Zer
  • @ Fat-Zer why this zero can not be added? I tried to do it via "\ 0", but the string is still not going to, just output byte-by-byte, and not by the integer value - Cotton Pericranium
  • can not be added only because you forgot to add it in the code ... in my opinion there are no errors in my opinion, except for a couple of suspicious moments ( flush not necessary and the fact that Read is written with a capital letter) ... maybe something is wrong with the transfer or with the reception further on the code ... - Fat-Zer

0