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 Motor by
Diff: main.cpp
- Revision:
- 3:8e9a3ba2f23e
- Parent:
- 2:c9df6ce2f77d
diff -r c9df6ce2f77d -r 8e9a3ba2f23e main.cpp --- a/main.cpp Sun May 31 07:20:38 2015 +0000 +++ b/main.cpp Wed Jan 27 16:55:07 2016 +0000 @@ -1,32 +1,42 @@ -/** Motor Beispiel - Motor an den oberen 2 Pins einstecken. +/** Motor und LED Beispiel aus IoT fuer Integratoren + Motor an den unteren 2 Pins einstecken. */ #include "mbed.h" #include "Motor.h" -Motor m1(D3, D2, D4); // PWM, Vorwaerts, Rueckwarts +DigitalOut led1( D10 ); +DigitalOut led2( D11 ); +Motor m1( D3, D2, D4 ); // PWM, Vorwaerts, Rueckwarts int main() { - printf( "Motor Test\n" ); + printf( "Motor Test...\n" ); while ( 1 ) { // rueckwaerts printf( "rueckwaerts\n" ); - for (float s = 0.5f; s < 1.0f ; s += 0.01f ) + led1 = 0; + led2 = 1; + for (float s = 0.5f; s < 1.0f ; s += 0.05f ) { m1.speed(s * -1); wait(0.4); } + led1 = 0; + led2 = 0; m1.speed( 0 ); wait( 1.0 ); - printf( "vorwaerts\n" ); - for (float s = 0.5f; s < 1.0f ; s += 0.01f ) + printf( "vorwaerts\n" ); + led1 = 1; + led2 = 0; + for (float s = 0.5f; s < 1.0f ; s += 0.05f ) { m1.speed(s); wait(0.4); } + led1 = 0; + led2 = 0; m1.speed( 0 ); wait( 1.0 ); }