smd.iotkit1.ch
/
Motor_DigitalOut
Motor und LED Beispiel aus IoT fuer Integratoren
Fork of Motor by
main.cpp@3:8e9a3ba2f23e, 2016-01-27 (annotated)
- Committer:
- marcel1691
- Date:
- Wed Jan 27 16:55:07 2016 +0000
- Revision:
- 3:8e9a3ba2f23e
- Parent:
- 2:c9df6ce2f77d
Motor und LED Beispiel aus IoT fuer Integratoren
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcel1691 | 3:8e9a3ba2f23e | 1 | /** Motor und LED Beispiel aus IoT fuer Integratoren |
marcel1691 | 3:8e9a3ba2f23e | 2 | Motor an den unteren 2 Pins einstecken. |
marcel1691 | 0:6d98ef70e4b9 | 3 | */ |
marcel1691 | 0:6d98ef70e4b9 | 4 | #include "mbed.h" |
marcel1691 | 0:6d98ef70e4b9 | 5 | #include "Motor.h" |
marcel1691 | 0:6d98ef70e4b9 | 6 | |
marcel1691 | 3:8e9a3ba2f23e | 7 | DigitalOut led1( D10 ); |
marcel1691 | 3:8e9a3ba2f23e | 8 | DigitalOut led2( D11 ); |
marcel1691 | 3:8e9a3ba2f23e | 9 | Motor m1( D3, D2, D4 ); // PWM, Vorwaerts, Rueckwarts |
marcel1691 | 0:6d98ef70e4b9 | 10 | |
marcel1691 | 0:6d98ef70e4b9 | 11 | int main() |
marcel1691 | 0:6d98ef70e4b9 | 12 | { |
marcel1691 | 3:8e9a3ba2f23e | 13 | printf( "Motor Test...\n" ); |
marcel1691 | 0:6d98ef70e4b9 | 14 | while ( 1 ) |
marcel1691 | 0:6d98ef70e4b9 | 15 | { |
marcel1691 | 0:6d98ef70e4b9 | 16 | // rueckwaerts |
marcel1691 | 0:6d98ef70e4b9 | 17 | printf( "rueckwaerts\n" ); |
marcel1691 | 3:8e9a3ba2f23e | 18 | led1 = 0; |
marcel1691 | 3:8e9a3ba2f23e | 19 | led2 = 1; |
marcel1691 | 3:8e9a3ba2f23e | 20 | for (float s = 0.5f; s < 1.0f ; s += 0.05f ) |
marcel1691 | 0:6d98ef70e4b9 | 21 | { |
marcel1691 | 0:6d98ef70e4b9 | 22 | m1.speed(s * -1); |
marcel1691 | 0:6d98ef70e4b9 | 23 | wait(0.4); |
marcel1691 | 0:6d98ef70e4b9 | 24 | } |
marcel1691 | 3:8e9a3ba2f23e | 25 | led1 = 0; |
marcel1691 | 3:8e9a3ba2f23e | 26 | led2 = 0; |
marcel1691 | 0:6d98ef70e4b9 | 27 | m1.speed( 0 ); |
marcel1691 | 0:6d98ef70e4b9 | 28 | wait( 1.0 ); |
marcel1691 | 0:6d98ef70e4b9 | 29 | |
marcel1691 | 3:8e9a3ba2f23e | 30 | printf( "vorwaerts\n" ); |
marcel1691 | 3:8e9a3ba2f23e | 31 | led1 = 1; |
marcel1691 | 3:8e9a3ba2f23e | 32 | led2 = 0; |
marcel1691 | 3:8e9a3ba2f23e | 33 | for (float s = 0.5f; s < 1.0f ; s += 0.05f ) |
marcel1691 | 0:6d98ef70e4b9 | 34 | { |
marcel1691 | 0:6d98ef70e4b9 | 35 | m1.speed(s); |
marcel1691 | 0:6d98ef70e4b9 | 36 | wait(0.4); |
marcel1691 | 0:6d98ef70e4b9 | 37 | } |
marcel1691 | 3:8e9a3ba2f23e | 38 | led1 = 0; |
marcel1691 | 3:8e9a3ba2f23e | 39 | led2 = 0; |
marcel1691 | 0:6d98ef70e4b9 | 40 | m1.speed( 0 ); |
marcel1691 | 0:6d98ef70e4b9 | 41 | wait( 1.0 ); |
marcel1691 | 0:6d98ef70e4b9 | 42 | } |
marcel1691 | 0:6d98ef70e4b9 | 43 | } |