1、ARDUINO 编程语法基础第1页结构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);第2页控制结构ifif.elseforswitch casewhi
2、ledo.whilebreakcontinuereturngoto第3页语法;(分号)(大括号)/(胆寒注释)/*/(多汗注释)#define#include第4页算术运算符=(assignment operator)+(addition)-(subtraction)*(multiplication)/(division)%(modulo)第5页比较运算符=(equal to)!=(not equal to)(greater than)=(greater than or equal to)第6页布尔运算符&(and)|(or)!(not)第7页指针运算符*dereference operato
3、r&reference operator第8页位运算符&(bitwise and)|(bitwise or)(bitwise xor)(bitwise not)(bitshift right)第9页复合运算符+(increment)-(decrement)+=(compound addition)-=(compound subtraction)*=(compound multiplication)/=(compound division)&=(compound bitwise and)|=(compound bitwise or)第10页数值数值常量HIGH|LOWINPUT|OUTPUT|I
4、NPUT_PULLUPtrue|falseinteger constantsfloating point constants第11页数值数值数据类型voidbooleancharunsigned charbyteintunsigned intwordlongunsigned longfloatdoublestring-char arrayString-objectarray第12页数值数值转换char()byte()int()word()long()float()第13页数值数值变量范围与限定符variable scopestaticvolatileconstUtilitiessizeof()
5、第14页函数函数数字数字 I/OpinMode()digitalWrite()digitalRead()第15页模拟模拟 I/OanalogReference()analogRead()analogWrite()-PWM第16页高级高级 I/Otone()noTone()shiftOut()shiftIn()pulseIn()第17页时间时间millis()micros()delay()delayMicroseconds()第18页数学数学min()max()abs()constrain()map()pow()sqrt()第19页三角函数三角函数sin()cos()tan()第20页随机数随机数randomSeed()random()第21页位与字节位与字节lowByte()highByte()bitRead()bitWrite()bitSet()bitClear()bit()第22页外部中止外部中止attachInterrupt()detachInterrupt()第23页通信通信SerialStream第24页USB(仅适合用于(仅适合用于Leonardo、Due、Micro)KeyboardMouse第25页