Last active
July 31, 2019 18:11
-
-
Save ReubenBTalbott/be7d2199a0d10304cec6ce019aba0c81 to your computer and use it in GitHub Desktop.
Arduino code that only half of it works.
This file contains 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 <WiFi.h> | |
char fling = 1; | |
bool detect = 1; | |
const char* ssid = "My network"; | |
const char* password = "MY wifi 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