Go Down

Topic: Problems with Serial Bus (Read 1 time) previous topic - next topic


You're going to need to service serial quite frequently to avoid buffer overflow. Every 200ms is not going to cut it - theoretically, you could get ~190 characters delivered in that time. Post (attach) your code if you need assistance in refactoring it to achieve this.


I put a , on the end of your string and the below code returned the entire string to the serial monitor.

Code: [Select]

//zoomkat 3-5-12 simple delimited ',' string parce
//from serial port input (via serial monitor)
//and print result out serial port
// CR/LF could also be a delimiter

String readString;

void setup() {
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded

void loop() {

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,
  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      //do stuff
      Serial.println(readString); //prints string to serial port out
      readString=""; //clears variable for new input     
    else {     
      readString += c; //makes the string readString

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131