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

Schematic

motors.png (148 KB) Emily Hart, 09/07/2009 10:07 pm

wheel.png (204 KB) Emily Hart, 09/07/2009 10:07 pm

motors_schematic.png (83.4 KB) Emily Hart, 09/16/2009 09:46 pm