Skip to content

Instantly share code, notes, and snippets.

@felixebert
Created July 2, 2016 04:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixebert/55f3f191aeee188f5299fd674fdd2bfc to your computer and use it in GitHub Desktop.
Save felixebert/55f3f191aeee188f5299fd674fdd2bfc to your computer and use it in GitHub Desktop.
#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