Adding open and close,
make the page look a bit nicer.
This commit is contained in:
41
src/main.cpp
41
src/main.cpp
@@ -132,7 +132,22 @@ const char* serverIndex =
|
|||||||
"</script>";
|
"</script>";
|
||||||
|
|
||||||
const char* movePage =
|
const char* movePage =
|
||||||
"<h1><a href='/rev'>REV</a></h1> <h1><a href='/fwd'>FWD</a></h1>";
|
"<html>"
|
||||||
|
"<head>"
|
||||||
|
"<style type='text/css'>"
|
||||||
|
"button {"
|
||||||
|
"width: 100;"
|
||||||
|
"height: 100;"
|
||||||
|
"} "
|
||||||
|
"</style>"
|
||||||
|
"</head>"
|
||||||
|
"<body>"
|
||||||
|
"<a href='http://192.168.10.141/close'><button>CLOSE</button></a>"
|
||||||
|
"<a href='http://192.168.10.141/open'><button>OPEN</button></a>"
|
||||||
|
"<a href='http://192.168.10.141/rev'><button>REV</button></a>"
|
||||||
|
"<a href='http://192.168.10.141/fwd'><button>FWD</button></a>"
|
||||||
|
"</body>"
|
||||||
|
"</html>";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setup function
|
* setup function
|
||||||
@@ -199,6 +214,30 @@ void setup(void) {
|
|||||||
Serial.println("Motor Access");
|
Serial.println("Motor Access");
|
||||||
server.send(200, "text/html", movePage);
|
server.send(200, "text/html", movePage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("/open", HTTP_GET, []() {
|
||||||
|
server.sendHeader("Connection", "close");
|
||||||
|
Serial.println("Opening");
|
||||||
|
digitalWrite(motor1Pin1, LOW);
|
||||||
|
digitalWrite(motor1Pin2, HIGH);
|
||||||
|
delay(3000);
|
||||||
|
// Stop the DC motor
|
||||||
|
digitalWrite(motor1Pin2, LOW);
|
||||||
|
|
||||||
|
server.send(200, "text/html", movePage);
|
||||||
|
});
|
||||||
|
server.on("/close", HTTP_GET, []() {
|
||||||
|
server.sendHeader("Connection", "close");
|
||||||
|
Serial.println("Closing");
|
||||||
|
digitalWrite(motor1Pin1, HIGH);
|
||||||
|
digitalWrite(motor1Pin2, LOW);
|
||||||
|
delay(3000);
|
||||||
|
// Stop the DC motor
|
||||||
|
digitalWrite(motor1Pin1, LOW);
|
||||||
|
|
||||||
|
server.send(200, "text/html", movePage);
|
||||||
|
});
|
||||||
|
|
||||||
server.on("/fwd", HTTP_GET, []() {
|
server.on("/fwd", HTTP_GET, []() {
|
||||||
server.sendHeader("Connection", "close");
|
server.sendHeader("Connection", "close");
|
||||||
// Move the DC motor forward at maximum speed
|
// Move the DC motor forward at maximum speed
|
||||||
|
|||||||
Reference in New Issue
Block a user