Motors¶
The motors turn the wheels, which move the robots.
Sample Code¶
#include <dragonfly_lib.h>
/*
* Drives the robot forward at full speed.
*/
void drive_forward()
{
motors_init(); // must be called before using any motor code
motor_l_set(FORWARD, 255); // set left motor to drive forward at the fastest speed
motor_r_set(FORWARD, 255); // set right motor to drive forward at the fastest speed
}
#include <dragonfly_lib.h>
/*
* Turns the robot to the right at a lower speed.
*/
void turn_right()
{
motors_init(); // must be called before using any motor code
motor_r_set(FORWARD, 200); // set right motor to drive forward
// the other motor is not on, so the robot turns right
}
Header File¶
For a full list of functions, see the motor code header file