Witam.
Mam taki kod i nie wiem co dalej zrobić. Chodzi mi o to żeby po naciśnięciu przycisku silnik obrócił się o zadaną ilość kroków i następnie się zatrzymał. Proszę o pomoc!!!!!!
Mam taki kod i nie wiem co dalej zrobić. Chodzi mi o to żeby po naciśnięciu przycisku silnik obrócił się o zadaną ilość kroków i następnie się zatrzymał. Proszę o pomoc!!!!!!
Kod:
// Include the AccelStepper library:
#include <AccelStepper.h>
// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 2
#define stepPin 3
#define motorInterfaceType 1
int btn1 = 5;
// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
void setup() {
// Set the maximum speed and acceleration:
stepper.setMaxSpeed(8000);
stepper.setAcceleration(500);
pinMode(btn1,INPUT);
}
void loop() {
if(digitalRead(btn1) == HIGH);
stepper.moveTo(32000);
stepper.runToPosition();
}