
Very simple operation samples of unipolar stepper motor. This code has been made to help beginners to learn the stepper motor. The history of the code shows the how to generate pulses from very basic level.
main.cpp@5:28bbda0fe9b5, 2014-01-11 (annotated)
- Committer:
- okano
- Date:
- Sat Jan 11 01:51:26 2014 +0000
- Revision:
- 5:28bbda0fe9b5
- Parent:
- 0:6e775c640f78
- Child:
- 6:11b35048d384
version 0-2 : Check BusOut by LED
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:6e775c640f78 | 1 | // stepper motor operation sample (learn it step by step). |
okano | 0:6e775c640f78 | 2 | // showing how to control a unipolar stepper motor by mbed digital output ports. |
okano | 0:6e775c640f78 | 3 | // |
okano | 5:28bbda0fe9b5 | 4 | // version 0-2 : Check BusOut by LED |
okano | 0:6e775c640f78 | 5 | |
okano | 0:6e775c640f78 | 6 | #include "mbed.h" |
okano | 0:6e775c640f78 | 7 | |
okano | 5:28bbda0fe9b5 | 8 | BusOut motor_out( LED1, LED2, LED3, LED4 ); |
okano | 0:6e775c640f78 | 9 | |
okano | 0:6e775c640f78 | 10 | int main() { |
okano | 0:6e775c640f78 | 11 | while(1) { |
okano | 0:6e775c640f78 | 12 | |
okano | 5:28bbda0fe9b5 | 13 | motor_out = 1; |
okano | 0:6e775c640f78 | 14 | wait( 0.2 ); |
okano | 0:6e775c640f78 | 15 | |
okano | 5:28bbda0fe9b5 | 16 | motor_out = 2; |
okano | 0:6e775c640f78 | 17 | wait( 0.2 ); |
okano | 0:6e775c640f78 | 18 | |
okano | 5:28bbda0fe9b5 | 19 | motor_out = 4; |
okano | 0:6e775c640f78 | 20 | wait( 0.2 ); |
okano | 0:6e775c640f78 | 21 | |
okano | 5:28bbda0fe9b5 | 22 | motor_out = 8; |
okano | 5:28bbda0fe9b5 | 23 | wait( 0.2 ); |
okano | 0:6e775c640f78 | 24 | } |
okano | 0:6e775c640f78 | 25 | } |