Created
September 15, 2019 21:51
-
-
Save alyatwa/87fba5586a27ef7ff7eaecd11d28916e to your computer and use it in GitHub Desktop.
stepper motor
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
// Arduino stepper motor control code | |
#include <Stepper.h> // Include the header file | |
// change this to the number of steps on your motor | |
#define STEPS 32 | |
// create an instance of the stepper class using the steps and pins | |
Stepper stepper(STEPS, 8, 10, 9, 11); | |
int val = 0; | |
void setup() { | |
Serial.begin(9600); | |
stepper.setSpeed(200); | |
} | |
void loop() { | |
if (Serial.available()>0) | |
{ | |
val = Serial.parseInt(); | |
stepper.step(val); | |
Serial.println(val); //for debugging | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment