Skip to content

Instantly share code, notes, and snippets.

@ReubenBTalbott
Created July 30, 2019 23:09
Show Gist options
  • Save ReubenBTalbott/35bcefc733adc0c9600c39ccf8995a5a to your computer and use it in GitHub Desktop.
Save ReubenBTalbott/35bcefc733adc0c9600c39ccf8995a5a to your computer and use it in GitHub Desktop.
Errors
#include <WiFi.h>
char fling = 1;
bool detect = 1;
const char* ssid = "My wifi SSID";
const char* password = "My super secret password!";
WiFiServer server(80);
void setup()
{
pinMode(2, OUTPUT);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
server.begin();
}
void loop() {
WiFiClient client = server.available(); // listen for incoming clients
if (client) { // if you get a client,
String req = client.readStringUntil('\r');
client.flush();
if (req.indexOf("/stat/1") != -1) {
fling = 1;
detect = 0;
}
else if (req.indexOf("/stat/2") != -1) {
fling = 2;
detect = 0;
}
}
if (fling == 1 && detect == 0) {
digitalWrite(2, HIGH);
}
detect = 1;
}
if (fling == 2 && detect == 0) {
digitalWrite(2, LOW);
}
detect = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment