OK... If you would like to use Blynk and have an access code required to open your garage, here is an example I put together using button and LCD widgets on virtual pins. The buttons are on V1, V2, V3, V4 and represent digits 1 to 4 respectively. The LCD widget in on virtual pin 5 (V5). You will need to create the corresponding project with widgets on Blynk, 4 buttons, 1 LCD.
* http://twitter.com/blynk_app
*
* Blynk library is licensed under MIT license
* This example code is in public domain.
*
**************************************************************
* This example runs directly on Oaks.
*
* Please be sure to select Oak
* in the Tools -> Board menu!
*
* Change Blynk auth token to run :)
*
**************************************************************/
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleOak.h>
//#include <SimpleTimer.h>
WidgetLCD lcd(V5); // Blynk LCD widget
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YOURAUTHTOKENGOESHERE";
int accessCODE[4] = {1,4,1,3}; // Modifiy to your liking and/or increase number of digits
int accessINPUT[4];
int digit = 0;
int OakLEDpin = 1; // Oak onboard LED pin 1
BLYNK_WRITE(V1) //Button Widget is writing to pin V1
{
if (param.asInt()==1) {
lcd.print(digit,1, "*");
accessINPUT[digit++] = 1;
digit = digit % 4;
if (digit == 0)
checkAccess();
}
}
BLYNK_WRITE(V2) //Button Widget is writing to pin V2
{
if (param.asInt()==1) {
lcd.print(digit,1, "*");
accessINPUT[digit++] = 2;
digit = digit % 4;
if (digit == 0)
checkAccess();
}
}
BLYNK_WRITE(V3) //Button Widget is writing to pin V3
{
if (param.asInt()==1) {
lcd.print(digit,1, "*");
accessINPUT[digit++] = 3;
digit = digit % 4;
if (digit == 0)
checkAccess();
}
}
BLYNK_WRITE(V4) //Button Widget is writing to pin V4
{
if (param.asInt()==1) {
lcd.print(digit,1, "*");
accessINPUT[digit++] = 4;
digit = digit % 4;
if (digit == 0)
checkAccess();
}
}
void checkAccess() {
for(int i=0; i<4; i++) {
if (accessINPUT[i] != accessCODE[i]) {
lcd.print(0,0, "NO CIGAR!");
lcd.print(0,1, " ");
digitalWrite(OakLEDpin,LOW);
return;
}
}
lcd.print(0,0, "Winner! ");
lcd.print(0,1, " ");
// Do something
digitalWrite(OakLEDpin,HIGH);
return;
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
pinMode(OakLEDpin, OUTPUT);
digitalWrite(OakLEDpin,LOW);
}
void loop() {
Blynk.run();
}