problem in printing the integer.

byte buttonPin =0;
String readString;

void setup() {
    ADMUX |= (1 << ADLAR); //left align the ADC value- so we can read highest 8 bits from ADCH register only
  ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); //prescaler 128 STO FACENDO UNA CONVERSIONE OGNI 0.104MS
  pinMode(A3, INPUT);
  Serial.begin(115200);
  Serial.println("<Arduino is ready>");
}

void loop() {
 buttonPin = digitalRead(A3);
  if (buttonPin==HIGH)
  {

    int  analog1 =analogRead(A0)/4;

    int  analog2 =analogRead(A1)/4;

    int  analog3 =analogRead(A2)/4;

    
 Serial.print(";");
  Serial.print(analog1);
   Serial.print(";");
//   delayMicroseconds(110);
//  Serial.print(";");
// Serial.print( analog2);
// delayMicroseconds(110);
//  Serial.print(";");
// Serial.print( analog3);
// delayMicroseconds(110);
//  Serial.println(";");
 // delay(1000);
  }
  else
  {
  recvWithStartEndMarkers();

}
  }

void recvWithStartEndMarkers() {
   //expect a string like wer;qwe rty;123 456;hyre kjhg;
        //or like hello world;who are you?;bye!;
        while (Serial.available()) {
        delay(10);  //small delay to allow input buffer to fill
    
        char c = Serial.read();  //gets one byte from serial buffer
               
        if (c == ';') {break;}  //breaks out of capture loop to print readstring
        readString += c; //makes the string readString
        }
      
         
  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n;
    char carray[9]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
  //  myservo.writeMicroseconds(n); // for microseconds
    //myservo.write(n); //for degees 0-180
    readString="";
  }  }

the output looks like this:

<Arduino is ready>
5
255
255
255
255
255
255
255
255
255
255
255
255
255
2
5
5
555
555555555555555555555522555525552255222222222222
5555555555555555
5
5
555555555555555555555555222222
5555555552222222
22222222222
555555522222
5555555555222222
2222
555555552222222
22222222
5555
55
5555555222222
555555
55555
5555555552255522222222

So, the first 13 prints are all right then it get crazy.
Suggestion?

:confused:

Where are the semicolons?

while (Serial.available()) {
delay(10); //small delay to allow input buffer to fill

That comment, and the code that goes with it is bullshit.

byte buttonPin =0;
String readString;

void setup() {
    ADMUX |= (1 << ADLAR); //left align the ADC value- so we can read highest 8 bits from ADCH register only
  ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); //prescaler 128 STO FACENDO UNA CONVERSIONE OGNI 0.104MS
  pinMode(A3, INPUT);
  Serial.begin(115200);
  Serial.println("<Arduino is ready>");
}

void loop() {
 buttonPin = digitalRead(A3);
  if (buttonPin==HIGH)
  {

    int  analog1 =analogRead(A0)/4;

    int  analog2 =analogRead(A1)/4;

    int  analog3 =analogRead(A2)/4;

    
 Serial.print(";");
  Serial.print(analog1);
   Serial.print(";");
//   delayMicroseconds(110);
//  Serial.print(";");
// Serial.print( analog2);
// delayMicroseconds(110);
//  Serial.print(";");
// Serial.print( analog3);
// delayMicroseconds(110);
//  Serial.println(";");
 // delay(1000);
  }
  else
  {
  recvWithStartEndMarkers();

}
  }

void recvWithStartEndMarkers() {
 
        while (Serial.available()) {
    
        char c = Serial.read();  //gets one byte from serial buffer
               
        if (c == ';') {break;}  //breaks out of capture loop to print readstring
        readString += c; //makes the string readString
        }
      
         
  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n;
    char carray[9]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
  //  myservo.writeMicroseconds(n); // for microseconds
    //myservo.write(n); //for degees 0-180
    readString="";
  }  }

Where are the semicolons?

Well they should disapper because:

if (c == ';') {break;}  //breaks out of capture loop to print readstring

That comment, and the code that goes with it is bullshit.

I mean with all the things that are wrong is truly necessary to put focus on a comment?

my problem here is receiving all data, saving them and then slip them.

    char carray[9]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray);

I really don't get this style of programming - if you want the string in a char buffer, why not put it there in the first place, instead of mucking around with Strings?

Please use the auto format tool before posting code - I get eye-ache reading this.

I mean with all the things that are wrong is truly necessary to put focus on a comment?

The comment is indicative of the problem. 10ms at 115200 is sufficient to overflow the input buffer nearly twice over.

The comment is indicative of the problem. 10ms at 115200 is sufficient to overflow the input buffer nearly twice over.

Thank you for the explanation AWOL.

With the previous comment was inpossible to understand what was wrong: Bullshit doesn't explain what was the issue.

I'm pretty sure the intention was to get you to think "This guy has a lot of posts and a lot of karma. Maybe he knows what he's talking about, and has spotted a problem with my code. I wonder if I can figure out what it is?"

That's how I read it anyway.

well, usually I don't interpret what people say me. I am very direct and I aspect the same (my mistake). We are in a forum where people from all the country read. Well HIGH CONTEXT is not understandable in the same way all around the world. That is why LOW CONTEXT should be used but that of course it is only my opinion. References: https://en.wikipedia.org/wiki/High-_and_low-context_cultures

That’s interesting - according to that page, I come from a low-context culture, yet from my limited understanding of anthropological concepts, I equate low-context with spoon-feeding, which I abhor.

I equate low-context with spoon-feeding, which I abhor.

They are quite different. Interaction LOW CONTEST •Low use of nonverbal elements. Message is carried more by words than by nonverbal means.

•Verbal message is explicit. Context is less important than words.

•Verbal message is direct; one spells things out exactly.

•Communication is seen as a way of exchanging information, ideas, and opinions. :smiling_imp:

•Disagreement is depersonalized. One withdraws from conflict with another and gets on with the task. Focus is on rational solutions, not personal ones. One can be explicit about another's bothersome behavior. :)

Interaction HIGH CONTEXT Interaction • High use of nonverbal elements; voice tone, facial expression, gestures, and eye movement carry significant parts of conversation.

•Verbal message is implicit; context (situation, people, nonverbal elements) is more important than words.

•Verbal message is indirect; one talks around the point and embellishes it.

•Communication is seen as an art form—a way of engaging someone.

• Disagreement is personalized. One is sensitive to conflict expressed in another's nonverbal communication. Conflict either must be solved before work can progress or must be avoided because it is personally threatening. ???

Have a nice weekend everybody. I will deal with my problem on monday!

usually I don't interpret what people say me

Maybe it's time to start

my problem here is receiving all data, saving them and then slip them.

Be sure to add either spell-checking or communication to that list. "Slip" them?

The way I see it, life is too short to waste time on misunderstandings.

It is best to be as easy to read as a digital clock.

Instead of this:

That comment, and the code that goes with it is bullshit.

what would have been more helpful would be something like:

"Ten milliseconds is much too long to wait here."

or

"You don't need a delay here. Try another strategy instead."

There was absolutely no need to use rude language.

That's how I read it anyway.

I read it as somebody with a personality disorder. Maybe a high post count is just an indication of no life beyond the forum. Sad.

my problem here is receiving all data, saving them and then slip them.

Can you give an example of the data string the arduino is receiving? Does the data string have an end of data marker?

The "comment" was intended for "YOU" to take a closer look at YOUR code.. All the rest of your commentary IS BS... IMNSHO..

Doc

The "comment" was intended for "YOU" to take a closer look at YOUR code..

The problem is that it isn't OP's code. Someone else late in this thread is under the impression that waiting for serial data to arrive is better than properly using delimiters and only reacting when the end of packet marker arrives, and keeps posting that crappy code.

OP, if you didn't like the comment, you could have asked "OK, so what do I do instead?", instead of getting all huffy.