Last active
August 29, 2015 14:19
-
-
Save sanbis1983/dd394ad0c1c1852bb3b8 to your computer and use it in GitHub Desktop.
step_MOTOR_TESTCODE_clockwise*2_anticlockwise*1
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 <Stepper.h> | |
#define STEPS 64 //定義步進馬達每圈的步數 | |
//steps:代表馬達轉完一圈需要多少步數。如果馬達上有標示每步的度數, | |
//將360除以這個角度,就可以得到所需要的步數(例如:360/3.6=100)。(int) | |
Stepper stepper(STEPS, 8, 10, 9, 11); | |
void setup() | |
{ | |
stepper.setSpeed(250); // 將馬達的速度設定成140RPM 最大 150~160 | |
} | |
void loop() | |
{ | |
stepper.step(2048);//正一圈 | |
delay(1000); | |
stepper.step(2048);//正一圈 | |
delay(1000); | |
stepper.step(-2048);//負一圈 | |
delay(1000); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment