smd.iotkit1.ch / Mbed 2 deprecated Motor_DigitalOut

Dependencies:   Motor mbed

Fork of Motor by smd.iotkit1.ch

main.cpp

Committer:
stefan1691
Date:
2015-05-31
Revision:
2:c9df6ce2f77d
Parent:
1:cd92955f8d4b
Child:
3:8e9a3ba2f23e

File content as of revision 2:c9df6ce2f77d:

/** Motor Beispiel
    Motor an den oberen 2 Pins einstecken.
*/
#include "mbed.h"
#include "Motor.h"

Motor m1(D3, D2, D4); // PWM, Vorwaerts, Rueckwarts

int main() 
{
    printf( "Motor Test\n" );
    while   ( 1 )
    {
        // rueckwaerts
        printf( "rueckwaerts\n" );
        for (float s = 0.5f; s < 1.0f ; s += 0.01f ) 
        {
           m1.speed(s * -1); 
           wait(0.4);
        }
        m1.speed( 0 );
        wait( 1.0 );
        
        printf( "vorwaerts\n" );        
        for (float s = 0.5f; s < 1.0f ; s += 0.01f ) 
        {
           m1.speed(s); 
           wait(0.4);
        }
        m1.speed( 0 );
        wait( 1.0 );   
    }
}