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.
main.cpp@0:42d3a9b29f42, 2017-09-28 (annotated)
- Committer:
- SMART_CLEO
- Date:
- Thu Sep 28 03:27:46 2017 +0000
- Revision:
- 0:42d3a9b29f42
SMART_CLEO
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| SMART_CLEO | 0:42d3a9b29f42 | 1 | #include "mbed.h" |
| SMART_CLEO | 0:42d3a9b29f42 | 2 | |
| SMART_CLEO | 0:42d3a9b29f42 | 3 | // 1A, 1B, 2A, 2B |
| SMART_CLEO | 0:42d3a9b29f42 | 4 | PinName pin_STEP[4] = {PA_5, PA_6, PA_7, PA_8}; |
| SMART_CLEO | 0:42d3a9b29f42 | 5 | |
| SMART_CLEO | 0:42d3a9b29f42 | 6 | BusOut Step(pin_STEP[0], pin_STEP[1], pin_STEP[2], pin_STEP[3]); |
| SMART_CLEO | 0:42d3a9b29f42 | 7 | |
| SMART_CLEO | 0:42d3a9b29f42 | 8 | uint8_t Phase_2[4] = {0x03, 0x06, 0x0C, 0x09}; |
| SMART_CLEO | 0:42d3a9b29f42 | 9 | |
| SMART_CLEO | 0:42d3a9b29f42 | 10 | int main() |
| SMART_CLEO | 0:42d3a9b29f42 | 11 | { |
| SMART_CLEO | 0:42d3a9b29f42 | 12 | int count = 0; |
| SMART_CLEO | 0:42d3a9b29f42 | 13 | // Step off |
| SMART_CLEO | 0:42d3a9b29f42 | 14 | Step = 0; |
| SMART_CLEO | 0:42d3a9b29f42 | 15 | |
| SMART_CLEO | 0:42d3a9b29f42 | 16 | while(1){ |
| SMART_CLEO | 0:42d3a9b29f42 | 17 | // CW(360deg) |
| SMART_CLEO | 0:42d3a9b29f42 | 18 | for(count = 0; count <= 200; count++) |
| SMART_CLEO | 0:42d3a9b29f42 | 19 | { |
| SMART_CLEO | 0:42d3a9b29f42 | 20 | Step = Phase_2[count%4]; |
| SMART_CLEO | 0:42d3a9b29f42 | 21 | wait(0.005); |
| SMART_CLEO | 0:42d3a9b29f42 | 22 | } |
| SMART_CLEO | 0:42d3a9b29f42 | 23 | Step = 0; |
| SMART_CLEO | 0:42d3a9b29f42 | 24 | wait(2); |
| SMART_CLEO | 0:42d3a9b29f42 | 25 | // CCW(-360deg) |
| SMART_CLEO | 0:42d3a9b29f42 | 26 | for(count = 200; count >= 0; count--) |
| SMART_CLEO | 0:42d3a9b29f42 | 27 | { |
| SMART_CLEO | 0:42d3a9b29f42 | 28 | Step = Phase_2[count%4]; |
| SMART_CLEO | 0:42d3a9b29f42 | 29 | wait(0.005); |
| SMART_CLEO | 0:42d3a9b29f42 | 30 | } |
| SMART_CLEO | 0:42d3a9b29f42 | 31 | Step = 0; |
| SMART_CLEO | 0:42d3a9b29f42 | 32 | wait(2); |
| SMART_CLEO | 0:42d3a9b29f42 | 33 | } |
| SMART_CLEO | 0:42d3a9b29f42 | 34 | } |