Created
July 2, 2016 04:00
-
-
Save felixebert/55f3f191aeee188f5299fd674fdd2bfc to your computer and use it in GitHub Desktop.
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 | |
ESP8266WebServer server(80); //creating the server at port 80 | |
void setup() { | |
Serial.begin(115200); | |
server.on("/action1", action1); | |
server.begin(); | |
pinMode(5, OUTPUT); | |
} | |
void action1() { | |
String value = server.arg("value"); //this lets you access a query param (http://x.x.x.x/action1?value=1) | |
int number = value.toInt(); | |
if(number == 0) { | |
digitalWrite(5, LOW); | |
} else { | |
digitalWrite(5, HIGH); | |
} | |
} | |
void loop() { | |
server.handleClient(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment