= 指派运算子
将等号右边的数值储存到等号左边的变数中。
这个单等号在 C 语言中叫做指派运算子,它和数学上的等号意义不同,不是指相等;指派运算子将会指示微控制器将等号右边的任何值、算式的结果或函式的回传值,储存到等号左边的变数之中。
范例
int sensVal; // 宣告一个变数名称为 sensVal senVal = analogRead(0); // 读取类比输入脚位 0 上的电压值,并且将它储存到这个 senVal 变数之中
提醒
指派运算子左边的变数型别大小应该要相符或大于右边值的型别大小,否则储存进去的数值会不正确。
请不要将单等号 (=) 与双等号 (==) 搞混,单等号是指派运算子,而双等号是比较运算子。
See also
- if (comparison operators)
- char
- int
- long
本页由热血青年 LBU 译自英文版。
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.