Final version of stepper motor demo
Dependencies: Stepper_Motor_X27168 mbed
Fork of Stepper_Motor_Demo by
main.cpp@2:5c8e6d22f773, 2016-03-16 (annotated)
- Committer:
- yhbyhb4433
- Date:
- Wed Mar 16 19:29:29 2016 +0000
- Revision:
- 2:5c8e6d22f773
- Parent:
- 1:5de876de6423
Final version of stepper motor demo program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
agarg45 | 0:71dc3ae7e2eb | 1 | #include "mbed.h" |
agarg45 | 0:71dc3ae7e2eb | 2 | #include "StepperMotor_X27168.h" |
agarg45 | 0:71dc3ae7e2eb | 3 | |
agarg45 | 0:71dc3ae7e2eb | 4 | StepperMotor_X27168 smotor(p25, p26, p23, p22); |
agarg45 | 0:71dc3ae7e2eb | 5 | int main() { |
agarg45 | 0:71dc3ae7e2eb | 6 | |
yhbyhb4433 | 1:5de876de6423 | 7 | smotor.init(); //initialize the motor |
agarg45 | 0:71dc3ae7e2eb | 8 | |
yhbyhb4433 | 2:5c8e6d22f773 | 9 | smotor.set_speed(800); //set the speed to 500 steps per second |
yhbyhb4433 | 1:5de876de6423 | 10 | |
yhbyhb4433 | 1:5de876de6423 | 11 | smotor.angle_position(45); |
yhbyhb4433 | 1:5de876de6423 | 12 | wait(1); |
agarg45 | 0:71dc3ae7e2eb | 13 | |
agarg45 | 0:71dc3ae7e2eb | 14 | smotor.angle_position(270); |
yhbyhb4433 | 1:5de876de6423 | 15 | wait(1); |
yhbyhb4433 | 1:5de876de6423 | 16 | |
yhbyhb4433 | 1:5de876de6423 | 17 | smotor.angle_position(90); |
yhbyhb4433 | 1:5de876de6423 | 18 | wait(1); |
yhbyhb4433 | 1:5de876de6423 | 19 | |
yhbyhb4433 | 1:5de876de6423 | 20 | smotor.angle_position(180); |
yhbyhb4433 | 1:5de876de6423 | 21 | wait(1); |
agarg45 | 0:71dc3ae7e2eb | 22 | |
yhbyhb4433 | 1:5de876de6423 | 23 | smotor.angle_position(315); |
yhbyhb4433 | 1:5de876de6423 | 24 | wait(1); |
yhbyhb4433 | 1:5de876de6423 | 25 | |
yhbyhb4433 | 1:5de876de6423 | 26 | smotor.angle_position(45); |
yhbyhb4433 | 1:5de876de6423 | 27 | wait(1); |
yhbyhb4433 | 1:5de876de6423 | 28 | |
yhbyhb4433 | 1:5de876de6423 | 29 | smotor.angle_position(0); |
yhbyhb4433 | 1:5de876de6423 | 30 | wait(1); |
yhbyhb4433 | 1:5de876de6423 | 31 | |
agarg45 | 0:71dc3ae7e2eb | 32 | } |