您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 综合/其它 > ARDUINO编程语法基础
ARDUINO编程语法基础结构setup()loop()当项目开始运行时会调用setup()函数常我们在其中初始化一些变量、引脚状态及一些调用的库等loop函数是一个循环体,其中的程序将会不断的运行示例intbuttonPin=3;voidsetup(){Serial.begin(9600);pinMode(buttonPin,INPUT);}voidloop(){if(digitalRead(buttonPin)==HIGH)serialWrite('H');elseserialWrite('L');delay(1000);}控制结构•if•if...else•for•switchcase•while•do...while•break•continue•return•goto语法•;(分号)•{}(大括号)•//(胆寒注释)•/**/(多汗注释)•#define•#include算术运算符•=(assignmentoperator)•+(addition)•-(subtraction)•*(multiplication)•/(division)•%(modulo)比较运算符•==(equalto)•!=(notequalto)•(lessthan)•(greaterthan)•=(lessthanorequalto)•=(greaterthanorequalto)布尔运算符•&&(and)•||(or)•!(not)指针运算符•*dereferenceoperator•&referenceoperator位运算符•&(bitwiseand)•|(bitwiseor)•^(bitwisexor)•~(bitwisenot)•(bitshiftleft)•(bitshiftright)复合运算符•++(increment)•--(decrement)•+=(compoundaddition)•-=(compoundsubtraction)•*=(compoundmultiplication)•/=(compounddivision)•&=(compoundbitwiseand)•|=(compoundbitwiseor)数值•常量•HIGH|LOW•INPUT|OUTPUT|INPUT_PULLUP•true|false•integerconstants•floatingpointconstants数值•数据类型•void•boolean•char•unsignedchar•byte•int•unsignedint•word•long•unsignedlong•float•double•string-chararray•String-object•array数值•转换•char()•byte()•int()•word()•long()•float()数值•变量范围与限定符•variablescope•static•volatile•const•Utilities•sizeof()函数•数字I/O•pinMode()•digitalWrite()•digitalRead()模拟I/O•analogReference()•analogRead()•analogWrite()-PWM高级I/O•tone()•noTone()•shiftOut()•shiftIn()•pulseIn()时间•millis()•micros()•delay()•delayMicroseconds()数学•min()•max()•abs()•constrain()•map()•pow()•sqrt()三角函数•sin()•cos()•tan()随机数•randomSeed()•random()位与字节•lowByte()•highByte()•bitRead()•bitWrite()•bitSet()•bitClear()•bit()外部中断•attachInterrupt()•detachInterrupt()通信•Serial•StreamUSB(仅适用于Leonardo、Due、Micro)•Keyboard•Mouse
本文标题:ARDUINO编程语法基础
链接地址:https://www.777doc.com/doc-2898518 .html