![](/media/cache/profiles/a8849b052492b5106526b2331e526138.50x50_q85.jpg)
main.cpp@0:6058a90858b3, 2009-11-22 (annotated)
- Committer:
- user153739798366067129
- Date:
- Sun Nov 22 05:18:57 2009 +0000
- Revision:
- 0:6058a90858b3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
user153739798366067129 | 0:6058a90858b3 | 1 | // This is another test, this time using pwm to control the clock. it runs different |
user153739798366067129 | 0:6058a90858b3 | 2 | // speeds for a certain amount of time. |
user153739798366067129 | 0:6058a90858b3 | 3 | // i am using a circuit built around a STK672-330 with connected stepper. |
user153739798366067129 | 0:6058a90858b3 | 4 | |
user153739798366067129 | 0:6058a90858b3 | 5 | |
user153739798366067129 | 0:6058a90858b3 | 6 | |
user153739798366067129 | 0:6058a90858b3 | 7 | #include "mbed.h" |
user153739798366067129 | 0:6058a90858b3 | 8 | |
user153739798366067129 | 0:6058a90858b3 | 9 | PwmOut clk(21); |
user153739798366067129 | 0:6058a90858b3 | 10 | |
user153739798366067129 | 0:6058a90858b3 | 11 | DigitalOut enable(5); |
user153739798366067129 | 0:6058a90858b3 | 12 | DigitalOut direction(6); |
user153739798366067129 | 0:6058a90858b3 | 13 | |
user153739798366067129 | 0:6058a90858b3 | 14 | int i = 0; |
user153739798366067129 | 0:6058a90858b3 | 15 | |
user153739798366067129 | 0:6058a90858b3 | 16 | int main() |
user153739798366067129 | 0:6058a90858b3 | 17 | { |
user153739798366067129 | 0:6058a90858b3 | 18 | |
user153739798366067129 | 0:6058a90858b3 | 19 | clk.period_us(1000); |
user153739798366067129 | 0:6058a90858b3 | 20 | |
user153739798366067129 | 0:6058a90858b3 | 21 | enable = 1; |
user153739798366067129 | 0:6058a90858b3 | 22 | direction = 1; |
user153739798366067129 | 0:6058a90858b3 | 23 | clk = 0.5; |
user153739798366067129 | 0:6058a90858b3 | 24 | |
user153739798366067129 | 0:6058a90858b3 | 25 | while (1) { |
user153739798366067129 | 0:6058a90858b3 | 26 | |
user153739798366067129 | 0:6058a90858b3 | 27 | clk.period_us(750); |
user153739798366067129 | 0:6058a90858b3 | 28 | clk = 0.5; |
user153739798366067129 | 0:6058a90858b3 | 29 | wait(2); |
user153739798366067129 | 0:6058a90858b3 | 30 | clk.period_us(500); |
user153739798366067129 | 0:6058a90858b3 | 31 | clk = 0.5; |
user153739798366067129 | 0:6058a90858b3 | 32 | wait(2); |
user153739798366067129 | 0:6058a90858b3 | 33 | clk.period_us(250); |
user153739798366067129 | 0:6058a90858b3 | 34 | clk = 0.5; |
user153739798366067129 | 0:6058a90858b3 | 35 | wait(2); |
user153739798366067129 | 0:6058a90858b3 | 36 | clk.period_us(500); |
user153739798366067129 | 0:6058a90858b3 | 37 | clk = 0.5; |
user153739798366067129 | 0:6058a90858b3 | 38 | wait(2); |
user153739798366067129 | 0:6058a90858b3 | 39 | } |
user153739798366067129 | 0:6058a90858b3 | 40 | } |