arduino 语法中怎么把一个数字形式的字符串转换成数值?

 我来答
kefanmail
2011-12-22 · TA获得超过690个赞
知道小有建树答主
回答量:419
采纳率:0%
帮助的人:391万
展开全部
用函数: int()

例如 int i = int("123");

下面是语法介绍:
Description
Converts a value to the int data type.
Syntax
int(x)
Parameters
x: a value of any type
Returns
int
更多追问追答
追问
非常感谢!请看下下面的代码问题出在哪里,
int i=int("45");
void setup()
{
Serial.begin (9600);
pinMode(9,OUTPUT);
}
void loop()
{
analogWrite(9,i);

按说应该在9脚输出45大小的PWM,可是实际测试却没有……
追答
直接写 analogWrite(9, 45);  有反应没
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式