Speed ​​of serial communication

khalil_dz
Posts: 8
Joined: Sat Dec 22, 2018 4:14 pm

Speed ​​of serial communication

Postby khalil_dz » Wed Jan 30, 2019 12:08 am

Hi all
1-I am looking for a function or method faster than the function (Serial.readStringUntil ('\ r') or Serial.parseInt ()).
I think two functions took a long time(+6ms) for receiver (4 int) same time.
The program I used
  1. int m_1,m_2,m_3,m_4; //// m=[1000 2000]
  2. String inString = "";
  3. void setup() {
  4.    Serial.begin(115200);                                                
  5. }
  6.  void loop() {
  7.       if(Serial.available()>0){
  8.       for(int i = 0; i < 4;i++){
  9.     String rread = Serial.readStringUntil(',');
  10.        switch(i){
  11.         case 0 :
  12.                    m_1 = rread.toInt();
  13.         break;
  14.         case 1 :
  15.                     m_2 = rread.toInt();
  16.         break;
  17.         case 2 :
  18.                     m_3 = rread.toInt();
  19.         break;
  20.         case 3 :
  21.                     m_4 = rread.toInt();
  22.         break;
  23.             }
  24.     }
  25. ////print for verification////
  26.                    Serial.println(m_1);
  27.                    Serial.println(m_2);
  28.                    Serial.println(m_3);
  29.                    Serial.println(m_4);
  30.     }
  31.  }
2-how to use the serial read function to receive (4 int) same time.

Who is online

Users browsing this forum: FatihIDFORUM and 50 guests