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.
Fork of HelloWorld by
main.cpp@3:ce96e87c0c53, 2017-02-22 (annotated)
- Committer:
- gardamerinos
- Date:
- Wed Feb 22 01:13:30 2017 +0000
- Revision:
- 3:ce96e87c0c53
- Parent:
- 2:0c6fdc8ec9a9
- Child:
- 4:1070977b83e9
basic motion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:fb6bbc10ffa0 | 1 | #include "mbed.h" |
simon | 0:fb6bbc10ffa0 | 2 | |
gardamerinos | 3:ce96e87c0c53 | 3 | DigitalOut stepperX_DIR(p30); |
gardamerinos | 2:0c6fdc8ec9a9 | 4 | PwmOut stepperX_PWM(p21); |
simon | 0:fb6bbc10ffa0 | 5 | |
simon | 0:fb6bbc10ffa0 | 6 | int main() { |
gardamerinos | 3:ce96e87c0c53 | 7 | stepperX_PWM.period_us(150); // 0.15 millisecond period |
gardamerinos | 2:0c6fdc8ec9a9 | 8 | stepperX_PWM.write(0.50f); // 50% duty cycle, relative to period |
simon | 0:fb6bbc10ffa0 | 9 | while(1) { |
gardamerinos | 2:0c6fdc8ec9a9 | 10 | stepperX_DIR = 1; |
gardamerinos | 2:0c6fdc8ec9a9 | 11 | wait(1); |
gardamerinos | 2:0c6fdc8ec9a9 | 12 | stepperX_DIR = 0; |
gardamerinos | 2:0c6fdc8ec9a9 | 13 | wait(1); |
gardamerinos | 3:ce96e87c0c53 | 14 | stepperX_PWM.write(0); |
gardamerinos | 3:ce96e87c0c53 | 15 | wait(1); |
gardamerinos | 3:ce96e87c0c53 | 16 | stepperX_PWM.write(0.5f); |
simon | 0:fb6bbc10ffa0 | 17 | } |
simon | 0:fb6bbc10ffa0 | 18 | } |