void loop() {
ts = millis();
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
delay(1000);
if ((ts - ts2 >= 60000) && (WiFi.status() == WL_CONNECTED)) {
read_sensor();
}
if ((ts - ts1 >= 5000) && (beep_state == true)) {
beep_state = false;
}
if ((digitalRead(PirPin1) == HIGH) && (beep_state == false) && (WiFi.status() == WL_CONNECTED)) {
while (digitalRead(PirPin1) == HIGH) delay(100);
Serial.println("Detect !");
Serial.print(abc);
Line_Notify1(message1);
beep_state = true;
}
delay(10);
ts = millis();
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
if ((ts - ts4 >= 60000) && (WiFi.status() == WL_CONNECTED)) {
read_sensor();
}
if ((ts - ts3 >= 5000) && (beep_state == true)) {
beep_state = false;
}
delay(1000);
if ((digitalRead(PirPin2) == HIGH) && (beep_state == false) && (WiFi.status() == WL_CONNECTED)) {
while (digitalRead(PirPin2) == HIGH) delay(100);
Serial.println("Detect !");
Serial.print(abcd);
Line_Notify1(message1);
beep_state = true;
}
delay(10);
ts = millis();
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
if ((ts - ts6 >= 60000) && (WiFi.status() == WL_CONNECTED)) {
read_sensor();
}
if ((ts - ts5 >= 5000) && (beep_state == true)) {
beep_state = false;
}
delay(1000);
if ((digitalRead(PirPin3) == HIGH) && (beep_state == false) && (WiFi.status() == WL_CONNECTED)) {
while (digitalRead(PirPin3) == HIGH) delay(100);
Serial.println("Detect !");
Serial.print(abcdf);
Line_Notify1(message1);
beep_state = true;
}
delay(10);
}
การใช้งานเขียนโปรแกรม Arduino ทางร้านมีแนะนำในคอร์สเรียน Arduino Starter ที่หน้าเว็บด้านบนซ้ายครับ