Created
August 12, 2018 18:37
-
-
Save dansku/575029043b83df43b082f4d908392599 to your computer and use it in GitHub Desktop.
door automation with blynk
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[] = "auth_code_goes_here"; | |
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() | |
{ | |
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