Skip to main content
Commonmark migration
Source Link

In my case i used a buffer and a delimiter. Specificaly: The reading is placed on the byte array untill the delimiter is reached.

##For example

For example

From the arduino IDE serial monitor im sending this: CAT;

Each letter will be placed inside the byte array and this will stop when the ; sign is entered. This migh be usefull because you can send the bytes whenever you can and they will remain in the array.

void loop(){
if(Serial.available() > 0) {
 
 char rec = Serial.read();

 if(rec == '.'){
    Serial.print("Here: ");
    for(int i = 0; i < sizeof(attitude); i++){
       Serial.print(attitude[i]); //print
       attitude[i] = (char)0;
    }
    attitudePointer = 0;
    Serial.println();
    
 }else{
   if(attitudePointer <= sizeof(attitude)){
      attitude[attitudePointer] = rec;
      attitudePointer++;
    }
  }

 }
}

In my case i used a buffer and a delimiter. Specificaly: The reading is placed on the byte array untill the delimiter is reached.

##For example

From the arduino IDE serial monitor im sending this: CAT;

Each letter will be placed inside the byte array and this will stop when the ; sign is entered. This migh be usefull because you can send the bytes whenever you can and they will remain in the array.

void loop(){
if(Serial.available() > 0) {
 
 char rec = Serial.read();

 if(rec == '.'){
    Serial.print("Here: ");
    for(int i = 0; i < sizeof(attitude); i++){
       Serial.print(attitude[i]); //print
       attitude[i] = (char)0;
    }
    attitudePointer = 0;
    Serial.println();
    
 }else{
   if(attitudePointer <= sizeof(attitude)){
      attitude[attitudePointer] = rec;
      attitudePointer++;
    }
  }

 }
}

In my case i used a buffer and a delimiter. Specificaly: The reading is placed on the byte array untill the delimiter is reached.

For example

From the arduino IDE serial monitor im sending this: CAT;

Each letter will be placed inside the byte array and this will stop when the ; sign is entered. This migh be usefull because you can send the bytes whenever you can and they will remain in the array.

void loop(){
if(Serial.available() > 0) {
 
 char rec = Serial.read();

 if(rec == '.'){
    Serial.print("Here: ");
    for(int i = 0; i < sizeof(attitude); i++){
       Serial.print(attitude[i]); //print
       attitude[i] = (char)0;
    }
    attitudePointer = 0;
    Serial.println();
    
 }else{
   if(attitudePointer <= sizeof(attitude)){
      attitude[attitudePointer] = rec;
      attitudePointer++;
    }
  }

 }
}
Source Link

In my case i used a buffer and a delimiter. Specificaly: The reading is placed on the byte array untill the delimiter is reached.

##For example

From the arduino IDE serial monitor im sending this: CAT;

Each letter will be placed inside the byte array and this will stop when the ; sign is entered. This migh be usefull because you can send the bytes whenever you can and they will remain in the array.

void loop(){
if(Serial.available() > 0) {
 
 char rec = Serial.read();

 if(rec == '.'){
    Serial.print("Here: ");
    for(int i = 0; i < sizeof(attitude); i++){
       Serial.print(attitude[i]); //print
       attitude[i] = (char)0;
    }
    attitudePointer = 0;
    Serial.println();
    
 }else{
   if(attitudePointer <= sizeof(attitude)){
      attitude[attitudePointer] = rec;
      attitudePointer++;
    }
  }

 }
}