Skip to content
Snippets Groups Projects
Commit df7f56bc authored by aliceg3's avatar aliceg3
Browse files

button controls motors & pressure

parent a880285f
No related branches found
No related tags found
No related merge requests found
/*********
Rui Santos
Complete project details at https://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/
https://randomnerdtutorials.com/esp32-async-web-server-espasyncwebserver-library/
*********/
// Import required libraries
......@@ -9,6 +8,8 @@
#include <ESPAsyncWebServer.h>
#include <AsyncTCP.h>
#include <Stepper.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
// Replace with your network credentials
const char* ssid = "Connectify-ESP32 Boot";
......@@ -28,6 +29,7 @@ const char* input_parameter2 = "state";
#define PRESSURE2GOAL 2034
Stepper motor(200, motorIN1, motorIN2, motorIN3, motorIN4);
//AccelStepper motor(AccelStepper::FULL4WIRE, motorIN1, motorIN2, motorIN3, motorIN4);
// current temperature & humidity, updated in loop()
int pressure1 = 0.0;
......@@ -126,7 +128,7 @@ setInterval(function ( ) {
};
xhttp.open("GET", "/pressure1", true);
xhttp.send();
}, 0.1 ) ;
}, 1000 ) ;
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
......@@ -137,7 +139,7 @@ setInterval(function ( ) {
};
xhttp.open("GET", "/pressure1status", true);
xhttp.send();
}, 0.1 ) ;
}, 1000 ) ;
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
......@@ -148,7 +150,7 @@ setInterval(function ( ) {
};
xhttp.open("GET", "/pressure2", true);
xhttp.send();
}, 0.1 ) ;
}, 1000 ) ;
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
......@@ -159,7 +161,7 @@ setInterval(function ( ) {
};
xhttp.open("GET", "/pressure2status", true);
xhttp.send();
}, 0.1 ) ;
}, 1000 ) ;
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
......@@ -170,7 +172,7 @@ setInterval(function ( ) {
};
xhttp.open("GET", "/motor1status", true);
xhttp.send();
}, 0.1 ) ;
}, 1000 ) ;
</script>
</html>)rawliteral";
......@@ -262,6 +264,25 @@ void setup(){
Serial.print(inputMessage1);
Serial.print(" - Set to: ");
Serial.println(inputMessage2);
if (inputMessage2.toInt() == 1){
motor1status="running!!!"; // doesn't work idk why
// motor.setSpeed(120);
// motor.setCurrentPosition(0);
// motor.setAcceleration(10);
//
// motor.moveTo(2000);
//
// while(motor.distanceToGo() <= 1000) {
// motor.setSpeed(80);
// motor.runToPosition();
// }
motor.setSpeed(60);
motor.step(500);
motor.setSpeed(0);
// motor1status = "motor stop";
}
request->send(200, "text/plain", "OK");
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment