2017年3月23日 星期四

SimpleTimer SET timer






// SimpleTimer SET timer

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "461w366wbb2e7d4ww6b7b0a0dw4d785da7c3b";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "74170287";
char pass[] = "24063173";

#define RELAY_PIN 2
int pinValue=0;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
void turnRelayOff1() {
    digitalWrite(RELAY_PIN, LOW);
    Blynk.virtualWrite(V1, LOW);
    Blynk.virtualWrite(V5, LOW);
    Serial.println("Relay disabled");
}

BLYNK_WRITE(V1){
  if (RELAY_PIN, LOW)
  Serial.println("Relay enabled");
  Blynk.virtualWrite(V5, 255);
  digitalWrite(RELAY_PIN, HIGH);
  timer.setTimeout(1000L*pinValue, turnRelayOff1);
}

BLYNK_WRITE(V2)
{
  pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V2 Slider value is: ");
  Serial.println(pinValue);
  turnRelayOff1();
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
  timer.run();
}

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...