Created
July 26, 2020 01:03
-
-
Save drbh/5f9dd83c5a40263429eba913aed16463 to your computer and use it in GitHub Desktop.
Simple door state checker - truncated to ignore networking code
This file contains hidden or 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
#include <ESP8266WiFi.h> | |
#include <EEPROM.h> | |
// networking and request related | |
int inputVal = 0; | |
int addr = 0; | |
int lastValue; | |
// networking and request related | |
void sendMessageToLambda(int currentState) { | |
// networking and request related | |
} | |
void setup() { | |
Serial.begin(9600); | |
Serial.setTimeout(2000); | |
Serial.println(""); | |
pinMode(2, OUTPUT); | |
} | |
void loop() { | |
inputVal = digitalRead(2); | |
if (inputVal > lastValue) { | |
Serial.println("Turned On"); | |
sendMessageToLambda(inputVal) | |
} | |
if (lastValue > inputVal) { | |
Serial.println("Turned Off"); | |
sendMessageToLambda(inputVal) | |
} | |
lastValue = inputVal; | |
// wait 10 seconds before next check | |
delay(10000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment