This shows you the differences between two versions of the page.
tutorials:arduino:stepper_motor [2014/02/27 21:01] aaron |
tutorials:arduino:stepper_motor [2014/02/28 10:20] (current) sam |
||
---|---|---|---|
Line 9: | Line 9: | ||
===== Abstract ===== | ===== Abstract ===== | ||
+ | How to do this,please refer to [[http://docs.cubieboard.org/tutorials/arduino/controlling_led |light led]] and [[http://docs.cubieboard.org/tutorials/arduino/connecting|how to connect cubieboard and arduino]] | ||
- | ===== Headline ===== | + | {{:tutorials:arduino:照片_4.jpg|400}} |
+ | {{:tutorials:arduino:照片_3.jpg|400}} | ||
- | ==== Headline ==== | + | ===== Schematics===== |
+ | {{:tutorials:arduino:stepper_.jpg|400}} | ||
+ | |||
+ | ==== Sorce Code==== | ||
+ | <code> | ||
+ | #include <Stepper.h> | ||
+ | |||
+ | #define STEPS 100 | ||
+ | |||
+ | Stepper stepper(STEPS, 8, 9, 10, 11); | ||
+ | |||
+ | int previous = 0; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | |||
+ | stepper.setSpeed(90); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | int val = analogRead(0); | ||
+ | |||
+ | |||
+ | stepper.step(val - previous); | ||
+ | |||
+ | previous = val; | ||
+ | } | ||
+ | |||
+ | |||
+ | </code> | ||