結構
setup()
loop()
控制結構
if
if…else
for
switch case
while
do… while
break
continue
return
goto
更多程式結構語法
; (分號)
{} (大括號)
// (單行註解)
/* */ (多行註解)
#define
#include
算術運算子
= (指派運算子)
+ (加法運算子)
- (減法運算子)
* (乘法運算子)
/ (除法運算子)
% (餘數運算子)
比較運算子
== (等於)
!= (不等於)
< (小於)
> (大於)
<= (小於等於)
>= (大於等於)
布林運算子
&& (and)
|| (or)
! (not)
指標運算子
* 取值運算子
& 取址運算子
位元運算子
& (位元 and)
| (位元 or)
^ (位元 xor)
~ (位元 not)
<< (位元左移運算)
>> (位元右移運算)
複合運算子
++ (遞增運算子)
- - (遞減運算子)
+= (複合加法運算)
-= (複合減法運算)
*= (複合乘法運算)
/= (複合除法運算)
&= (複合位元 and)
|= (複合位元 or)
變數
常量
HIGH | LOW
INPUT | OUTPUT | INPUT_PULLUP
true | false
整數常數
浮點常數
資料型別
void
boolean
char
unsigned char
byte
int
unsigned int
word
long
unsigned long
long long
unsigned long long
short
float
double
long double
string – 字元陣列
String – 物件
array
型別轉換
char()
byte()
int()
word()
long()
float()
double()
作用範圍及修飾字
變數作用範圍
static
volatile
const
工具
sizeof()
函式
數位 I/O 功能
pinMode()
digitalWrite()
digitalRead()
類比 I/O 功能
analogReference()
analogRead()
analogWrite() – PWM
analogReadResolution()
analogWriteResolution()
cpuTemperature()
進階 I/O 功能
tone()
noTone()
shiftOut()
shiftIn()
pulseIn()
時間
millis()
micros()
delay()
delayMicroseconds()
數學
min()
max()
abs()
constrain()
map()
pow()
sqrt()
三角函式
sin()
cos()
tan()
字元分析
isAlphaNumeric()
isAlpha()
isAscii()
isWhitespace()
isControl()
isDigit()
isGraph()
isLowerCase()
isPrintable()
isPunct()
isSpace()
isUpperCase()
isHexadecimalDigit()
隨機數
randomSeed()
random()
位元及位元組操作
lowByte()
highByte()
bitRead()
bitWrite()
bitSet()
bitClear()
bit()
外部中斷
attachInterrupt()
detachInterrupt()
中斷
interrupts()
noInterrupts()
通訊
Serial
Serial232
Serial485
Stream
USB
Keyboard
Mouse