Arduino UNO 串口发送浮点数问题?
如题,Arduino UNO 能向串口发送浮点数吗?我试了半天好像不行也?大神们有解决方法吗? 贴上你的算法。 /*ADC and send to COM float
*/
float T;
int a;
void setup() {
Serial.begin(115200);
}
void loop() {
a = analogRead(2);
delay(1000);
T = a/1024*5;
Serial.print("the date:");
Serial.print(T);
Serial.print("\n");//enter
} 林定祥 发表于 2015-3-7 19:09 static/image/common/back.gif
贴上你的算法。
:)~~~~~~~~~~~~~~~~~~ 可以直接转化成字符串发送,到电脑端还不是想怎么处理就怎么处理 summer_ndy 发表于 2015-3-7 21:48 static/image/common/back.gif
~~~~~~~~~~~~~~~~~~
T=a/1024*5改成T=a/1024.0*5试试,记得整数除整数是会是整数,整数除浮点数才可能出浮点数。:loveliness: 林定祥 发表于 2015-3-7 22:19 static/image/common/back.gif
T=a/1024*5改成T=a/1024.0*5试试,记得整数除整数是会是整数,整数除浮点数才可能出浮点数。:loveliness ...
:handshake 是这样的 , 非常感谢,这是我得到的数据
the date:0.60
the date:1.11
the date:1.34
the date:1.89
the date:2.48
the date:2.87
the date:3.17
the date:3.35
the date:3.36
页:
[1]