How to send float over serial

前端 未结 9 1926
Happy的楠姐
Happy的楠姐 2021-01-02 09:15

What\'s the best way to send float, double, and int16 over serial on Arduino?

The Serial.print() only sends val

9条回答
  •  猫巷女王i
    2021-01-02 09:48

    This simply works. Use Serial.println() function

    void setup() {
      Serial.begin(9600);
    
    }
    
    void loop() {
      float x = 23.45585888;
      Serial.println(x, 10);
      delay(1000);
    }
    

    And this is the output:

提交回复
热议问题