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

double switches

parent aaccef05
No related branches found
No related tags found
No related merge requests found
......@@ -34,9 +34,6 @@ const char* input_parameter2 = "state";
#define PRESSURE1GOAL 41
#define PRESSURE2GOAL 39
#define MOTOR1GOAL
#define MOTOR2GOAL
Stepper motor1(200, motor1IN1, motor1IN2, motor1IN3, motor1IN4);
Stepper motor2(200, motor2IN1, motor2IN2, motor2IN3, motor2IN4);
......@@ -51,6 +48,8 @@ String pressure1status = "NOT YET...";
String pressure2status = "NOT YET...";
String motor1status = "just started";
String motor2status = "just started";
int motor1goal;
int motor2goal;
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
......@@ -87,10 +86,14 @@ const char index_html[] PROGMEM = R"rawliteral(
body {max-width: 600px; margin:0px auto; padding-bottom: 25px;}
.switch {position: relative; display: inline-block; width: 120px; height: 68px}
.switch input {display: none}
.slider {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
.slider:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
input:checked+.slider {background-color: #b30000}
input:checked+.slider:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
.sliderON {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
.sliderON:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
input:checked+.sliderON {background-color: #20A110}
input:checked+.sliderON:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
.sliderOFF {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
.sliderOFF:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
input:checked+.sliderOFF {background-color: #b30000}
input:checked+.slideroFF:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
</style>
</head>
<body>
......@@ -120,13 +123,13 @@ const char index_html[] PROGMEM = R"rawliteral(
<i class="fas fa-wrench" style="color:#4a32a8;"></i>
<span class="sensorlabel">motor1 Status</span>
<span id="motor1status">%motor1STATUS%</span>
<sup class="units">torque</sup>
// <sup class="units">torque</sup>
</p>
<p>
<i class="fas fa-wrench" style="color:#4a32a8;"></i>
<span class="sensorlabel">motor2 Status</span>
<span id="motor2status">%motor2STATUS%</span>
<sup class="units">torque</sup>
// <sup class="units">torque</sup>
</p>
%BUTTONPLACEHOLDER%
<script>function toggleCheckbox(element) {
......@@ -238,7 +241,8 @@ String processor(const String& var){
}
else if(var == "BUTTONPLACEHOLDER"){
String buttons = "";
buttons += "<h4>Motor 1 Control</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"2\" " + outputState(2) + "><span class=\"slider\"></span></label>";
buttons += "<h4>TIGHTEN Boot</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"1\" " + outputState(2) + "><span class=\"sliderON\"></span></label>";
buttons += "<h4>Release Boot</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"2\" " + outputState(2) + "><span class=\"sliderOFF\"></span></label>";
return buttons;
}
return String();
......@@ -305,38 +309,27 @@ void setup(){
Serial.print(" - Set to: ");
Serial.println(inputMessage2);
if (inputMessage2.toInt() == 1){
// delay(200);
motor1status = "motor1 running"; // doesn't work idk why
motor2status = "awaiting...";
// motor11111.setSpeed(60);
// motor11111.step(500);
//// motor11111.setSpeed(0);
// digitalWrite(motor11111IN1, LOW);
// digitalWrite(motor11111IN2, LOW);
// digitalWrite(motor11111IN3, LOW);
// digitalWrite(motor11111IN4, LOW);
// delay(200);
// motor1status = "reset";
// motor11111.setCurrentPosition(0);
// motor11111.setAcceleration(10);
//
// motor11111.moveTo(2000);
//
// while(motor11111.distanceToGo() <= 1000) {
// motor11111.setSpeed(80);
// motor11111.runToPosition();
// }
// motor1status = "motor11111 stop";
if (inputMessage1.toInt() == 1){
if (inputMessage2.toInt() == 1){
motor1status = "Ankle motor tightening..."; // doesn't work idk why
motor2status = "Waiting...";
}
if (inputMessage2.toInt() == 0){
motor1status = "Off";
motor2status = "Off";
}
}
//
if (inputMessage2.toInt() == 0){
// motor11111.setSpeed(0);
motor1status = "reset";
motor2status = "reset";
if (inputMessage1.toInt() == 2) {
if (inputMessage2.toInt() == 1){
motor1status = "Ankle motor loosening..."; // doesn't work idk why
motor2status = "Waiting...";
}
if (inputMessage2.toInt() == 0){
motor1status = "Off";
motor2status = "Off";
}
}
request->send(200, "text/plain", "OK");
......@@ -358,28 +351,49 @@ void loop(){
int intervals2[7] = {0,0,0,0,0,0,0};
int intervalValues2[7] = {0,0,0,0,0,0,0};
if (motor1status == "motor1 running"){
if (motor1status == "Ankle motor tightening..."){
motor1.setSpeed(60);
motor1.step(500);
// motor11111.setSpeed(0);
digitalWrite(motor1IN1, LOW);
digitalWrite(motor1IN2, LOW);
digitalWrite(motor1IN3, LOW);
digitalWrite(motor1IN4, LOW);
motor1status = "stop";
motor1status = "Tightened";
motor2status = "running...";
motor2status = "Foot motor tightening...";
motor2.setSpeed(60);
motor2.step(-500);
// motor11111.setSpeed(0);
digitalWrite(motor2IN1, LOW);
digitalWrite(motor2IN2, LOW);
digitalWrite(motor2IN3, LOW);
digitalWrite(motor2IN4, LOW);
motor2status = "stop";
motor2status = "Tightened";
}
if (motor1status == "Ankle motor loosening ..."){
motor1.setSpeed(60);
motor1.step(500);
digitalWrite(motor1IN1, LOW);
digitalWrite(motor1IN2, LOW);
digitalWrite(motor1IN3, LOW);
digitalWrite(motor1IN4, LOW);
motor1status = "Loosened";
motor2status = "Foot motor loosening...";
motor2.setSpeed(60);
motor2.step(-500);
digitalWrite(motor2IN1, LOW);
digitalWrite(motor2IN2, LOW);
digitalWrite(motor2IN3, LOW);
digitalWrite(motor2IN4, LOW);
motor2status = "Loosened";
}
for(int counter = 0; counter < 10; counter ++) {
int a1 = analogRead(PRESSUREPIN1);
......
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