ช่วยด้วยครับ เครื่องทำงานปรกติ …แต่พอไฟดับ …แล้วไฟมา …รีเลย์ทำงานหมดทุกตัว แทนที่จะสถานะรีเลย์ควรยังไม่ทำงาน รบกวนด้วยครับ
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "f5e9d5a99e264c75a0c33b31102707b2";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Kunakorn";
char pass[] = "0877552200Satit";
WidgetLED led1(V1);
// We make these values volatile, as they are used in interrupt context
volatile bool pinChanged = false;
volatile int pinValue = 0;
// Most boards won't send data to WiFi out of interrupt handler.
// We just store the value and process it in the main loop.
void checkPin()
{
// Invert state, since button is "Active LOW"
pinValue = !digitalRead(2);
// Mark pin value changed
pinChanged = true;
}
void setup()
{
// Debug console
Serial.begin(9600);
//Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "oasiskit.com"; 8080);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
char server[] = "oasiskit.com";
int port = 8080;
// Make pin 2 HIGH by default
pinMode(2, INPUT_PULLUP);
// Attach INT to our handler
attachInterrupt(digitalPinToInterrupt(2), checkPin, CHANGE);
}
void loop()
{
Blynk.run();
if (pinChanged) {
// Process the value
if (pinValue) {
led1.on();
} else {
led1.off();
}
// Clear the mark, as we have processed the value
pinChanged = false;
}
}
Preformatted textPreformatted text``Preformatted text