https://gist.github.com/clive520/3d18bec33ef5c99bf57d4ef92dc97149
#include <WiFi.h>
#define LED_BUILTIN 2 // 連接到WIFI時,亮內建的LED
// 輸入你的SSID和密碼
const char *ssid = "book";
const char *password = "12345678";
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN,LOW) ;
Serial.begin(9600);
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password); //連接WIFI
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");//不成功時列印...
}
digitalWrite(LED_BUILTIN,HIGH) ;//成功時亮內建的LED
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());//WiFi.localIP()連接到的IP
}
void loop() {
}
沒有留言:
張貼留言