add wifi support
This commit is contained in:
parent
c578c5a1df
commit
f52f0ad51f
@ -1,15 +1,44 @@
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WebServer.h>
|
||||
|
||||
const char* ssid = "Decentrala";
|
||||
const char* password = "";
|
||||
|
||||
IPAddress local_IP(192, 168, 6, 102);
|
||||
IPAddress gateway(192, 168, 6, 1);
|
||||
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
IPAddress primaryDNS(192, 168, 6, 1);
|
||||
IPAddress secondaryDNS(9, 9, 9, 9);
|
||||
|
||||
WebServer server(80);
|
||||
|
||||
const int requestEnterPin = 36;
|
||||
const int openDoorPin = 32;
|
||||
int requestvalue;
|
||||
|
||||
int requestvalue = 0;
|
||||
|
||||
// setup code runs once:
|
||||
void setup() {
|
||||
pinMode(requestEnterPin, INPUT);
|
||||
pinMode(openDoorPin, OUTPUT);
|
||||
|
||||
delay(2);
|
||||
WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS);
|
||||
WiFi.begin(ssid);
|
||||
delay(3);
|
||||
|
||||
server.on("/open", openDoor);
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void openDoor() {
|
||||
analogWrite(openDoorPin, 255);
|
||||
digitalWrite(openDoorPin, HIGH);
|
||||
}
|
||||
|
||||
void closeDoor() {
|
||||
analogWrite(openDoorPin, LOW);
|
||||
}
|
||||
|
||||
bool askToOpen() {
|
||||
@ -25,6 +54,10 @@ bool askToOpen() {
|
||||
void loop() {
|
||||
if ( askToOpen() ) {
|
||||
openDoor();
|
||||
} else {
|
||||
closeDoor();
|
||||
}
|
||||
delay(1);
|
||||
//WiFi.status() != WL_CONNECTED
|
||||
//WiFi.localIP()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user