Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Stepper.h>
- #define STEPS_PER_MOTOR_REVOLUTION 32 //定義馬達解析度
- #define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048 //定義馬達輸出解析度
- Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11); //設定要輸出的IC腳位
- int Steps2Take;//轉幾度變數
- int stpperSpeed=800; //設定轉數變數
- void setup()
- {
- small_stepper.setSpeed(stpperSpeed); //設定轉動速度
- }
- void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
- {
- Steps2Take = STEPS_PER_OUTPUT_REVOLUTION ;
- small_stepper.step(Steps2Take); //開始轉動~
- delay(1000);
- Steps2Take = - STEPS_PER_OUTPUT_REVOLUTION; //將要轉幾度的數值變成負值,讓步進馬達反轉
- small_stepper.step(Steps2Take);
- delay(1000);
- }/* --(end main loop )-- */
- /* ( THE END ) */
Add Comment
Please, Sign In to add comment