-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
37 lines (34 loc) · 1 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/** Motor Beispiel
Motor an den oberen 2 Pins einstecken.
*/
#include "mbed.h"
#include "Motor.h"
Motor m1( MBED_CONF_IOTKIT_MOTOR1_PWM, MBED_CONF_IOTKIT_MOTOR1_FWD, MBED_CONF_IOTKIT_MOTOR1_REV ); // PWM, Vorwaerts, Rueckwarts
Motor m2( MBED_CONF_IOTKIT_MOTOR2_PWM, MBED_CONF_IOTKIT_MOTOR2_FWD, MBED_CONF_IOTKIT_MOTOR2_REV ); // PWM, Vorwaerts, Rueckwarts
int main()
{
printf( "Motor Test\n" );
while ( 1 )
{
// rueckwaerts
printf( "rueckwaerts\n" );
for (float s = 0.7f; s < 1.0f ; s += 0.01f )
{
m1.speed(s * -1);
m2.speed(s);
thread_sleep_for( 200 );
}
m1.speed( 0 );
thread_sleep_for( 1000 );
printf( "vorwaerts\n" );
for (float s = 0.7f; s < 1.0f ; s += 0.01f )
{
m1.speed(s);
m2.speed(s * -1);
thread_sleep_for( 200 );
}
m1.speed( 0 );
m2.speed( 0 );
thread_sleep_for( 1000 );
}
}