Speed of serial communication
Posted: 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
2-how to use the serial read function to receive (4 int) same time.
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
- int m_1,m_2,m_3,m_4; //// m=[1000 2000]
- String inString = "";
- void setup() {
- Serial.begin(115200);
- }
- void loop() {
- if(Serial.available()>0){
- for(int i = 0; i < 4;i++){
- String rread = Serial.readStringUntil(',');
- switch(i){
- case 0 :
- m_1 = rread.toInt();
- break;
- case 1 :
- m_2 = rread.toInt();
- break;
- case 2 :
- m_3 = rread.toInt();
- break;
- case 3 :
- m_4 = rread.toInt();
- break;
- }
- }
- ////print for verification////
- Serial.println(m_1);
- Serial.println(m_2);
- Serial.println(m_3);
- Serial.println(m_4);
- }
- }