Created
July 15, 2019 04:49
-
-
Save paulwinex/51e8e33b204503c2d9528f76d0697eaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CustomStepper.h> | |
CustomStepper stepper(2, 3, 4, 5); | |
int key_pin = 12; | |
int KEY_PRESSED = 0; | |
int is_rotate = false; | |
void setup() | |
{ | |
pinMode(key_pin, INPUT); | |
stepper.setRPM(12); | |
stepper.setSPR(4075.7728395); | |
Serial.begin(9600); | |
Serial.println("Start"); | |
} | |
void loop() | |
{ | |
// значение кнопки | |
KEY_PRESSED = digitalRead(key_pin); | |
if (stepper.isDone() && KEY_PRESSED == 1){ | |
Serial.println("Rotate"); | |
stepper.setDirection(CCW); | |
stepper.rotate(); | |
is_rotate = true; | |
} | |
if (KEY_PRESSED == 0 && is_rotate == true){ | |
Serial.println("Stop"); | |
stepper.setDirection(STOP); | |
is_rotate = false; | |
} | |
stepper.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment