// Stepper motor on Wokwi!

#include <Stepper.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

const int btnUp = 0; 
const int btnDown = 2; 
const int btnRight = 3; 
const int btnLeft = 1; 
const int btnEnter = 5; 


const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
int mmPasos = 90;
  double mms;

void setup() {
  
  // set the speed at 60 rpm:
  myStepper.setSpeed(30); 
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
 while (!Serial.available()) {

  }
  mms = Serial.parseInt();


  Serial.print("milimetros a extruir: ");
  Serial.println(mms);
  double pasosExtrusion = (mms * mmPasos)/1;
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(pasosExtrusion);
  delay(500);

  

 /* // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);*/
}
Loading
ssd1306