Arduino-什么是[/n.]?

Arduino-什么是[/n.]?,arduino,Arduino,我在arduino用电位计调光,我发现一个网站告诉我把模拟值(0-1023)转换成电压(0-255)。转换为255除以1023并与电位计读数相乘的线。这行代码是ledswrite=(255./1023.)*potRead。我试着写的是ledswrite=(255/1023)*potRead,带有句点,但代码不会运行 什么是/n. 作业 ledWrite = (255./1023.) * potRead; 相当于 ledWrite = (255.0 / 1023.0) * potRead; 也

我在arduino用电位计调光,我发现一个网站告诉我把模拟值(0-1023)转换成电压(0-255)。转换为255除以1023并与电位计读数相乘的线。这行代码是
ledswrite=(255./1023.)*potRead。我试着写的是
ledswrite=(255/1023)*potRead,带有句点,但代码不会运行

什么是
/n.

作业

ledWrite = (255./1023.) * potRead;
相当于

ledWrite = (255.0 / 1023.0) * potRead;
也就是说,可以省略尾随零

在Arduino Uno上,常数被解释为双倍,除法结果为双倍值

,请注意,在大多数Arduino板上,双精度和浮点精度相同(4字节),但Arduino板除外


在下面的行中

ledWrite = (255/1023) * potRead;
这两个数字文本被解释为整数,除法运算是整数之间的除法运算,在本例中,除法运算总是返回0,因为255小于| 1023 |