Door Security Sensor

Door Security Sensor

Code

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID   "YourTemplateID"


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Your token here";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "robocircuits";
char pass[] = "robocircuits";
boolean state, pstate = 0;
void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(15,INPUT);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
  state = digitalRead(15);
  if(state != pstate)
  {
    Blynk.virtualWrite(V1,state);
    pstate = state;
  }
}

Leave a Reply