欢迎来到天天文库
浏览记录
ID:49038298
大小:147.42 KB
页数:25页
时间:2020-01-30
《ARDUINO 编程语法基础.ppt》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、ARDUINO编程语法基础结构setup()loop()当项目开始运行时会调用setup()函数常我们在其中初始化一些变量、引脚状态及一些调用的库等loop函数是一个循环体,其中的程序将会不断的运行示例intbuttonPin=3;voidsetup(){Serial.begin(9600);pinMode(buttonPin,INPUT);}voidloop(){if(digitalRead(buttonPin)==HIGH)serialWrite('H');elseserialWrite('L');delay(
2、1000);}控制结构ifif...elseforswitchcasewhiledo...whilebreakcontinuereturngoto语法;(分号){}(大括号)//(胆寒注释)/**/(多汗注释)#define#include算术运算符=(assignmentoperator)+(addition)-(subtraction)*(multiplication)/(division)%(modulo)比较运算符==(equalto)!=(notequalto)<(lessthan)>(greaterth
3、an)<=(lessthanorequalto)>=(greaterthanorequalto)布尔运算符&&(and)
4、
5、(or)!(not)指针运算符*dereferenceoperator&referenceoperator位运算符&(bitwiseand)
6、(bitwiseor)^(bitwisexor)~(bitwisenot)<<(bitshiftleft)>>(bitshiftright)复合运算符++(increment)--(decrement)+=(compoundaddition)-=(com
7、poundsubtraction)*=(compoundmultiplication)/=(compounddivision)&=(compoundbitwiseand)
8、=(compoundbitwiseor)数值常量HIGH
9、LOWINPUT
10、OUTPUT
11、INPUT_PULLUPtrue
12、falseintegerconstantsfloatingpointconstants数值数据类型voidbooleancharunsignedcharbyteintunsignedintwordlongunsignedlo
13、ngfloatdoublestring-chararrayString-objectarray数值转换char()byte()int()word()long()float()数值变量范围与限定符variablescopestaticvolatileconstUtilitiessizeof()函数数字I/OpinMode()digitalWrite()digitalRead()模拟I/OanalogReference()analogRead()analogWrite()-PWM高级I/Otone()noTone()s
14、hiftOut()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()
15、通信SerialStreamUSB(仅适用于Leonardo、Due、Micro)KeyboardMouse
此文档下载收益归作者所有