#include // Define a stepper and the pins it will use AccelStepper stepper(AccelStepper::DRIVER,A1,A4); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5 AccelStepper stepper1(AccelStepper::DRIVER,A3,A2); long steps = 0; long rounds = 0; int indeks = 1; int vaihto = 0; int apu = 0; int roundz = 0; int nextChar = 1; void setup() { stepper.setMaxSpeed(650); stepper.setAcceleration(150); stepper1.setMaxSpeed(5.0); stepper1.setAcceleration(1000.0); stepper1.moveTo(19); Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } } void loop(){ if (Serial.available()) { nextChar = Serial.read(); if (nextChar == '0') { rounds = 21; steps = rounds*200; //Serial.println(steps); stepper.moveTo(steps); while (stepper.distanceToGo() != 0) { if (indeks = 199){ roundz = stepper.currentPosition()/200; indeks == 0; vaihto == 1; } indeks++; if (vaihto = 1){ Serial.println(roundz); vaihto=0; } stepper.run(); if (stepper1.distanceToGo() == 0) stepper1.moveTo(-stepper1.currentPosition()); stepper1.run(); } } } }