《ARDUINO编程语法基础.ppt》由会员分享,可在线阅读,更多相关《ARDUINO编程语法基础.ppt(25页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、ARDUINO 编程语法基础结构setup()loop()当项目开始运行时会调用setup()函数 常我们在其中初始化一些变量、引脚状态及一些调用的库等loop函数是一个循环体,其中的程序将会不断的运行 示例示例int buttonPin=3;void setup()Serial.begin(9600);pinMode(buttonPin,INPUT);void loop()if(digitalRead(buttonPin)=HIGH)serialWrite(H);else serialWrite(L);delay(1000);控制结构ifif.elseforswitch casewhiled
2、o.whilebreakcontinuereturngoto语法;(分号)(大括号)/(胆寒注释)/*/(多汗注释)#define#include算术运算符=(assignment operator)+(addition)-(subtraction)*(multiplication)/(division)%(modulo)比较运算符=(equal to)!=(not equal to)(greater than)=(greater than or equal to)布尔运算符&(and)|(or)!(not)指针运算符*dereference operator&reference operat
3、or位运算符&(bitwise and)|(bitwise or)(bitwise xor)(bitwise not)(bitshift right)复合运算符+(increment)-(decrement)+=(compound addition)-=(compound subtraction)*=(compound multiplication)/=(compound division)&=(compound bitwise and)|=(compound bitwise or)数值数值常量HIGH|LOWINPUT|OUTPUT|INPUT_PULLUPtrue|falseinteger
4、 constantsfloating point constants数值数值数据类型voidbooleancharunsigned charbyteintunsigned intwordlongunsigned longfloatdoublestring-char arrayString-objectarray数值数值转换char()byte()int()word()long()float()数值数值变量范围与限定符variable scopestaticvolatileconstUtilitiessizeof()函数函数数字数字 I/OpinMode()digitalWrite()digit
5、alRead()模拟模拟 I/OanalogReference()analogRead()analogWrite()-PWM高级高级 I/Otone()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()通信通信SerialStreamUSB(仅适用于(仅适用于Leonardo、Due、Micro)KeyboardMouse