Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed StepperMotor
main.cpp@1:7ae2ba4231d5, 2017-09-13 (annotated)
- Committer:
- okano
- Date:
- Wed Sep 13 04:31:19 2017 +0000
- Revision:
- 1:7ae2ba4231d5
- Parent:
- 0:9fdf81f6f8e9
program updated to include latest library
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 | } |