Created
August 11, 2018 21:34
-
-
Save dansku/3f3c05474273a131c568ad606e8b0e28 to your computer and use it in GitHub Desktop.
blynk open house door app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BLYNK_PRINT Serial | |
#include <blynk.h> | |
// You should get Auth Token in the Blynk App. | |
char auth[] = ""; | |
int relayPin = D7; // choose the pin for the LED | |
// blynk function | |
BLYNK_WRITE(V1) | |
{ | |
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable | |
if(pinValue == 1){ | |
openDoor(); | |
} | |
} | |
void openDoor() { | |
// Open Door | |
digitalWrite(relayPin, LOW); | |
delay(1500); | |
digitalWrite(relayPin, HIGH); | |
Particle.publish("house_door_open"); // Slack web hook to open the door | |
} | |
void setup() | |
{ | |
Serial.begin(9600); // Debug console | |
delay(5000); // Allow board to settle | |
Blynk.begin(auth); // Blynk auth | |
pinMode(relayPin, OUTPUT); // Set relay as output | |
digitalWrite(relayPin, HIGH); // Initialize relay pin as HIGH | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment