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();
}

沒有留言:

張貼留言

RFID TI 培訓影片系列

RFID TI 培訓影片系列  https://www.ti.com/zh-tw/video/series/rfid.html 培訓影片系列 RFID 隨著創新技術日益發展,RFID 和 RF 術語越來越容易讓人混淆。本訓練系列詳細介紹了使用案例、權衡技術優缺點,讓您清楚知道該選...