#include "Web.h"
void LEDcontrol(char i, bool B);
const char* ssid = "你家中的路由器SSID";
const char* password = "你家中的路由器密碼";
uint8_t LED = D0; //設定板載按鈕方便測試不用接線路
bool pin = LOW;//其實也可以不用這句,端看個人用途
//設定80port,我記得預設也是80port可以自己改成其他的
ESP8266WebServer server(80);
void setup() {
//---------------設定腳位
pinMode(LED,OUTPUT);
digitalWrite(LED,pin);
//---------------開啟監看視窗
Serial.begin(115200);
// --------------啟用SPIFFS檔案系統
SPIFFS.begin();
//---------------給連接網路一點時間
Serial.print("\nWifi Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
delay(100);
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
setserver_on(); //自己寫的function 內容請移到Web.ino看
server.onNotFound([](){
if (!handleFileRead(server.uri())) {
server.send(404, "text/plain", "FileNotFound");
}
});
//------------------啟動伺服器
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
delay(100);
}