arduino 中如何将字符串型转换为float型?

arduino 中如何将字符串型转换为float型?我要在串口输入字符串,比如“12.34”,要把它转换为float,给连接电机的输出端口作为电机速度。arduino 中如何将字符串型转换为float型?我要在串口输入字符串,比如“12.34”,要把它转换为float,给连接电机的输出端口作为电机速度。
高手指教啊

第1个回答  2015-05-15
String s="1234";
float a=s.toFloat();
第2个回答  2014-02-17
#include "stdlib.h"
float f;
char* b="12.34";
f=atof(b);
第3个回答  2014-02-14
你试试看,
定义一个变量B
串口输入的是A,字符型
加一句:B=(float)A;
我也没试过。本回答被网友采纳
相似回答