Created
August 13, 2020 01:23
-
-
Save clive520/3d18bec33ef5c99bf57d4ef92dc97149 to your computer and use it in GitHub Desktop.
WIFI03_連接WIFI_ESP32 NodeMCU 32S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment