Skip to content

Instantly share code, notes, and snippets.

@angipp01
Last active October 21, 2020 03:45
Show Gist options
  • Save angipp01/77f42a17579c30c8f1e66de360e61495 to your computer and use it in GitHub Desktop.
Save angipp01/77f42a17579c30c8f1e66de360e61495 to your computer and use it in GitHub Desktop.
Garage door openers with LCD & LED status.
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on NodeMCU.
Note: This requires ESP8266 support package:
https://github.com/esp8266/Arduino
Please be sure to select the right NodeMCU module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Blynk Key";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
// Select your pin with contact
const int btnPin1 = D1; // Relay contact for Door 1
const int btnPin2 = D2; // Relay contact for Door 2
WidgetLED led1(V1); //Match to the LED from the Blynk app
WidgetLED led2(V2);//Match to the LED from the Blynk app
WidgetLCD lcd1(V3); // Identifies if door is open and closed for door 1.
WidgetLCD lcd2(V4); // Identifies if door is open and closed for door 1.
BlynkTimer timer;
// V1 LED Widget represents the physical contact state
boolean btnState1 = false;
void buttonLedWidget1()
{
// Read contact
boolean isPressed = (digitalRead(btnPin1) == LOW);
// If state has changed...
if (isPressed != btnState1) {
if (isPressed) {
lcd1.clear(); //Use it to clear the LCD Widget
lcd1.print(4, 0, "Dad's door"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
lcd1.print(4, 1, "open");
led1.on();
} else {
led1.off();
lcd1.clear(); //Use it to clear the LCD Widget
lcd1.print(4, 0, "Dad's door"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
lcd1.print(4, 1, "closed");
}
btnState1 = isPressed;
}
}
// V2 LED Widget represents the physical contact state
boolean btnState2 = false;
void buttonLedWidget2()
{
// Read contact2
boolean isPressed = (digitalRead(btnPin2) == LOW);
// If state has changed...
if (isPressed != btnState2) {
if (isPressed) {
lcd2.clear(); //Use it to clear the LCD Widget
lcd2.print(4, 0, "Mom's door"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
lcd2.print(4, 1, "open");
led2.on();
} else {
led2.off();
lcd2.clear(); //Use it to clear the LCD Widget
lcd2.print(4, 0, "Mom's door"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
lcd2.print(4, 1, "closed");
}
btnState2 = isPressed;
}
}
void setup()
{
// Debug console
Serial.begin(15200);
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);
// Setup physical button pin (active low)
pinMode(btnPin1, INPUT_PULLUP);
timer.setInterval(500L, buttonLedWidget1);
pinMode(btnPin2, INPUT_PULLUP);
timer.setInterval(500L, buttonLedWidget2);
}
void loop()
{
Blynk.run();
timer.run();
}
@angipp01
Copy link
Author

I have this run for 1 week solid and it hasn't crashed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment