WiFi.begin()
描述
初始化 WiFi 函式庫並回傳目前的網路狀態。
語法
WiFi.begin();
WiFi.begin(ssid);
WiFi.begin(ssid, pass);
WiFi.begin(ssid, keyIndex, key);
參數
ssid
:欲連線的無線網路的 SSID
keyIndex
:使用 WEP 加密的無線網路可以儲存 4 組不同的鑰匙,keyIndex
用來指示要使用的鑰匙
key
:連線到 WEP 加密的無線網路時使用的鑰匙
pass
:連線到 WPA 加密的無線網路時使用的密碼
回傳
-WL_CONNECTED
:連線至網路
-WL_IDLE_STATUS
:沒有連線至網路,處於待命狀態
範例
#include <WiFi.h> //無線網路的 SSID char ssid[] = "yourNetwork"; //WPA 的密碼 char pass[] = "secretPassword"; void setup() { WiFi.begin(ssid, pass); } void loop () {}
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.