Update garage/Garage.ino
This commit is contained in:
+17
-8
@@ -1,15 +1,17 @@
|
||||
#include "ESP8266WiFi.h"
|
||||
#include "ESP8266WebServer.h"
|
||||
|
||||
// https://wiki.wemos.cc/products:d1:d1_mini
|
||||
// https://techtutorialsx.com/2016/10/03/esp8266-setting-a-simple-http-webserver/
|
||||
const char* SSID = "LeWe";
|
||||
const char* PASSWORD = "5275274365464843";
|
||||
const char* SSID = "SSID";
|
||||
const char* PASSWORD = "password";
|
||||
ESP8266WebServer server(80);
|
||||
|
||||
const int remotePin = D1;
|
||||
const int remoteButton = D2;
|
||||
const int motorPin = D3;
|
||||
const int motorButton = D4;
|
||||
const int motorPin = D2;
|
||||
|
||||
const int remoteButton = D5;
|
||||
const int motorButton = D6;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@@ -23,8 +25,9 @@ void setup() {
|
||||
|
||||
pinMode(BUILTIN_LED, OUTPUT);
|
||||
pinMode(remotePin, OUTPUT);
|
||||
pinMode(buttonPin, INPUT);
|
||||
pinMode(remoteButton, INPUT);
|
||||
pinMode(motorPin, OUTPUT);
|
||||
pinMode(motorButton, INPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -36,12 +39,12 @@ void loop() {
|
||||
connectWifi();
|
||||
}
|
||||
|
||||
if (digitalRead(remoteButton) == LOW) {
|
||||
if (digitalRead(remoteButton) == HIGH) {
|
||||
Serial.println("Remote button pressed");
|
||||
triggerRemote();
|
||||
}
|
||||
|
||||
if (digitalRead(motorButton) == LOW) {
|
||||
if (digitalRead(motorButton) == HIGH) {
|
||||
Serial.println("Motor button pressed");
|
||||
triggerMotor();
|
||||
}
|
||||
@@ -59,6 +62,12 @@ void handleTriggerMotor() {
|
||||
triggerMotor();
|
||||
}
|
||||
|
||||
void handleTriggerAll() {
|
||||
Serial.println("handleTriggerAll()");
|
||||
server.send(200, "text/plain", "Trigger all");
|
||||
triggerAll();
|
||||
}
|
||||
|
||||
void triggerRemote() {
|
||||
digitalWrite(remotePin, HIGH);
|
||||
digitalWrite(BUILTIN_LED, LOW);
|
||||
|
||||
Reference in New Issue
Block a user