StepperMotor class lib simple sample
Dependencies: mbed StepperMotor
Components pages
Components pages are available for bipolar
and unipolar
motor libraries
main.cpp@0:9fdf81f6f8e9, 2010-11-25 (annotated)
- Committer:
- okano
- Date:
- Thu Nov 25 11:18:21 2010 +0000
- Revision:
- 0:9fdf81f6f8e9
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:9fdf81f6f8e9 | 1 | #include "mbed.h" |
okano | 0:9fdf81f6f8e9 | 2 | #include "StepperMotor.h" |
okano | 0:9fdf81f6f8e9 | 3 | |
okano | 0:9fdf81f6f8e9 | 4 | BusOut leds( LED4, LED3, LED2, LED1 ); |
okano | 0:9fdf81f6f8e9 | 5 | StepperMotor m( p21, p22, p23, p24 ); |
okano | 0:9fdf81f6f8e9 | 6 | |
okano | 0:9fdf81f6f8e9 | 7 | int main() { |
okano | 0:9fdf81f6f8e9 | 8 | m.set_sync_mode( StepperMotor::SYNCHRONOUS ); |
okano | 0:9fdf81f6f8e9 | 9 | m.set_power_ctrl( true ); |
okano | 0:9fdf81f6f8e9 | 10 | |
okano | 0:9fdf81f6f8e9 | 11 | while ( 1 ) { |
okano | 0:9fdf81f6f8e9 | 12 | |
okano | 0:9fdf81f6f8e9 | 13 | leds = 1; |
okano | 0:9fdf81f6f8e9 | 14 | m.go_angle( 120 ); |
okano | 0:9fdf81f6f8e9 | 15 | wait( 0.5 ); |
okano | 0:9fdf81f6f8e9 | 16 | |
okano | 0:9fdf81f6f8e9 | 17 | leds = 2; |
okano | 0:9fdf81f6f8e9 | 18 | m.go_angle( 240 ); |
okano | 0:9fdf81f6f8e9 | 19 | wait( 0.5 ); |
okano | 0:9fdf81f6f8e9 | 20 | |
okano | 0:9fdf81f6f8e9 | 21 | leds = 3; |
okano | 0:9fdf81f6f8e9 | 22 | m.go_angle( 0 ); |
okano | 0:9fdf81f6f8e9 | 23 | wait( 0.5 ); |
okano | 0:9fdf81f6f8e9 | 24 | |
okano | 0:9fdf81f6f8e9 | 25 | leds = 4; |
okano | 0:9fdf81f6f8e9 | 26 | m.go_angle( 240 ); |
okano | 0:9fdf81f6f8e9 | 27 | wait( 0.5 ); |
okano | 0:9fdf81f6f8e9 | 28 | |
okano | 0:9fdf81f6f8e9 | 29 | leds = 5; |
okano | 0:9fdf81f6f8e9 | 30 | m.go_angle( 120 ); |
okano | 0:9fdf81f6f8e9 | 31 | wait( 0.5 ); |
okano | 0:9fdf81f6f8e9 | 32 | |
okano | 0:9fdf81f6f8e9 | 33 | leds = 6; |
okano | 0:9fdf81f6f8e9 | 34 | m.go_angle( 0 ); |
okano | 0:9fdf81f6f8e9 | 35 | wait( 0.5 ); |
okano | 0:9fdf81f6f8e9 | 36 | } |
okano | 0:9fdf81f6f8e9 | 37 | } |