How to read a string value with a delimiter on Arduino?

后端 未结 7 908
小鲜肉
小鲜肉 2020-12-10 03:34

I have to manage servos from a computer.

So I have to send manage messages from computer to Arduino. I need manage the number of servo and the corner. I\'m thinking

相关标签:
7条回答
  • 2020-12-10 04:26

    It looks like you just need to correct

      foo = '';  >>to>>  foo = "";
    
      foo += Serial.read();  >>to>>  foo += char(Serial.read());
    

    I made also shomething similar..:

    void loop(){
      while (myExp == "") {
        myExp = myReadSerialStr();
        delay(100);
      }
    }    
    
    String myReadSerialStr() {
      String str = "";
      while (Serial.available () > 0) {
        str += char(Serial.read ());
      }
      return str;
    }
    
    0 讨论(0)
提交回复
热议问题