Skip to content
Snippets Groups Projects
Commit 2a7589de authored by patelpb's avatar patelpb
Browse files

Updated coiling code

parent e41a2dbc
Branches master
No related merge requests found
#include <Stepper.h>
#include <ESP.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
const int rpm = 200;
const int MAXSTEPS = 10;
// for your motor
//asdfasdfasdf
......@@ -16,34 +18,51 @@ Stepper myStepper(stepsPerRevolution, PIN1, PIN2, PIN3, PIN4);
int stepCount = 0; // number of steps the motor has taken
void do_steps(int num_steps){
int stepsPerSecond = stepsPerRevolution / (60 * rpm);
//int run_
int doSteps(int num_steps){
int numRevs = 0;
int do_count = num_steps / MAXSTEPS;
int count_remainder = num_steps % MAXSTEPS;
for(int i = 0; i < do_count; ++i){
myStepper.step(-MAXSTEPS);
//Serial.print("Increment: ");
if (i % 20 == 0){
Serial.printf("Number of Revolutions: %d\n", numRevs++);
}
ESP.wdtFeed(); //yield; feeds the watchdog (resets the software timer)
}
myStepper.step(count_remainder);
ESP.wdtFeed();
return numRevs;
}
void setup() {
wdt_disable();
ESP.wdtDisable();
pinMode(PIN1, OUTPUT);
pinMode(PIN2, OUTPUT);
pinMode(PIN3, OUTPUT);
pinMode(PIN4, OUTPUT);
Serial.println("asdfsdF");
Serial.begin(115200);
myStepper.setSpeed(rpm);
// step 1/100 of a revolution:
int numRevolutions = (int) 1e5;
doSteps(numRevolutions * stepsPerRevolution);
Serial.println(stepCount);
}
void loop() {
// step 1/100 of a revolution:
int numRevolutions = 10;
myStepper.step(numRevolutions * stepsPerRevolution);
Serial.println(stepCount);
delay(500);
ESP.wdtFeed();
//delay(500);
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment