#include <stdio.h>
#ifdef __WIN32__
#include <windows.h>
#else
#include <unistd.h>
#define Sleep( msec ) usleep(( msec ) * 1000 )
#endif
int main( void )
{
char s[ 256 ], name_port[ 16 ];
int i;
uint8_t sn, sn_port;
uint8_t port = OUTPUT_B;
printf( "Waiting the EV3 brick online...\n" );
printf( "*** ( EV3 ) Hello! ***\n" );
printf(
"Set mode of the EV3 output port (%s)...\n",
ev3_port_name( port, EXT_PORT__NONE_, 0, name_port ));
printf( "%s: %s\n", name_port, s );
}
Sleep( 200 );
printf( "Found DC motors:\n" );
for ( i = 0; i < DESC_LIMIT; i++ ) {
if ( ev3_dc[ i ].type_inx != DC_TYPE__NONE_ ) {
printf(
" type = %s\n",
ev3_dc_type( ev3_dc[ i ].type_inx ));
}
}
printf( "DC motor is found, run for 5 sec...\n" );
printf( "state: %s\n", s );
}
Sleep( 5000 );
printf( "state: %s\n", s );
}
} else {
printf( "DC motor is NOT found\n" );
}
Sleep( 200 );
printf( "Reset mode of the EV3 output port...\n" );
printf( "%s: %s\n", name_port, s );
}
printf( "*** ( EV3 ) Bye! ***\n" );
return ( 0 );
}