ปัญหา ปิดสวิตซ์แล้วไม่ดับ

ปัญหา ปิดสวิตซ์แล้วไม่ดับ

diff --git a/ESP8266/.vscode/arduino.json b/ESP8266/.vscode/arduino.json
index def0a8a..3d152df 100644
--- a/ESP8266/.vscode/arduino.json
+++ b/ESP8266/.vscode/arduino.json
@@ -2,5 +2,5 @@
     "board": "esp8266:esp8266:nodemcuv2",
     "configuration": "xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200",
     "port": "COM5",
-    "sketch": "Reset_all_By_V7\\Reset_all_By_V7.ino"
+    "sketch": "SW_cannot_off\\SW_cannot_off.ino"
 }
\ No newline at end of file
diff --git a/ESP8266/SW_cannot_off/SW_cannot_off.ino b/ESP8266/SW_cannot_off/SW_cannot_off.ino
new file mode 100644
index 0000000..0af2d28
--- /dev/null
+++ b/ESP8266/SW_cannot_off/SW_cannot_off.ino
@@ -0,0 +1,81 @@
+#include <ESP8266WiFi.h>
+#include <WiFiClientSecureAxTLS.h> 
+void Line_Notify(String message) ;
+
+#define WIFI_SSID "wasanfern" // ชื่อไวไฟ
+#define WIFI_PASSWORD "2317012345"//รหัสผ่านไวไฟ
+
+// Line token
+#define LINE_TOKEN "UAsdAKjCdCamsmQXGwIXGrZTzc41EHQPfe1oToO1jUW"// ไลน์token
+#define Switch D2 //สวิทช์
+#define relay D3 //รีเลย์
+String message = "ช่วยด้วยอันตราย"; // เขียนข้อความที่ต้องการ
+
+void setup() {
+  pinMode(Switch, INPUT); 
+  pinMode(relay, OUTPUT);
+  Serial.begin(9600);
+  digitalWrite(relay,LOW);
+  WiFi.mode(WIFI_STA);
+  // connect to wifi.
+  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
+  Serial.print("connecting");
+
+  while (WiFi.status() != WL_CONNECTED) {
+    Serial.print(".");
+    delay(500);
+  }
+  Serial.println();
+  Serial.print("connected: ");
+  Serial.println(WiFi.localIP());
+}
+
+void loop() {
+  if (digitalRead(Switch) == HIGH) {
+//    while(digitalRead(Switch) == HIGH){ 
+//   delay(10);
+   Serial.println("Enter !");
+   Line_Notify(message); //ฟังชั่นที่ใช้ในการส่ง
+   delay(10);
+   digitalWrite(relay,HIGH); //ไซเรนทำงาน
+   delay(5000);// เวลาที่ตั้งให้ไซเรนดัง 5000= 5 วินาที
+  }
+  else
+  {
+   digitalWrite(relay,LOW); //ไซเรนหยุดทำงาน
+  }
+ }
+
+
+void Line_Notify(String message) {
+  axTLS::WiFiClientSecure client; // กรณีขึ้น Error ให้ลบ axTLS:: ข้างหน้าทิ้ง
+
+  if (!client.connect("notify-api.line.me", 443)) {
+    Serial.println("connection failed");
+    return;   
+  }
+
+  String req = "";
+  req += "POST /api/notify HTTP/1.1\r\n";
+  req += "Host: notify-api.line.me\r\n";
+  req += "Authorization: Bearer " + String(LINE_TOKEN) + "\r\n";
+  req += "Cache-Control: no-cache\r\n";
+  req += "User-Agent: ESP8266\r\n";
+  req += "Connection: close\r\n";
+  req += "Content-Type: application/x-www-form-urlencoded\r\n";
+  req += "Content-Length: " + String(String("message=" + message).length()) + "\r\n";
+  req += "\r\n";
+  req += "message=" + message;
+  // Serial.println(req);
+  client.print(req);
+    
+  delay(20);
+
+  // Serial.println("-------------");
+  while(client.connected()) {
+    String line = client.readStringUntil('\n');
+    if (line == "\r") {
+      break;
+    }
+  }
+}
\ No newline at end of file

GitHub
sha: 2f5ec9a6