Home Page | Language Reference (extended) | SD Reference | Libraries | Comparison | Changes


Robot

Write Your Own Firmware

The Robot Motor Board is intended to work as a "state machine", which means it receives commands from the Robot Control Board and executes them accordingly. It also returns data when requested. The default motor board firmware does not house much intelligence, but does not need to be adjusted for most applications.

You can, however, extend the functionality of the motor board by defining your own modes or creating your own command. To do this, you must modify the motor control board library files.

These instructions are for people already comfortable with programming.

Modes

The robot has a number of pre-defined modes that instruct the motor board how to operate. For example, there is the "line following mode". When entering this mode, the motor board will read values from the infrared sensor array mounted on the bottom of the board, calculate the desired direction of robot and manipulate the motors directly.

You can change modes with setMode() one the Control Board.

You can define your own modes. To create a new mode, you need to define the mode in both Control Board and Motor Board, and write the logic for the desired behavior.

Define a New Mode

//motor board modes
#define MODE_SIMPLE 0
#define MODE_LINE_FOLLOW 1
#define MODE_ADJUST_MOTOR 2
#define MODE_IR_CONTROL 3

To create a new command, you need to define the command code and write the send/receive code for it.

Define a New Command

//Command code
#define COMMAND_SWITCH_MODE 0
#define COMMAND_RUN 10
#define COMMAND_MOTORS_STOP 11
..........
#define COMMAND_READ_TRIM_RE 81
#define COMMAND_PAUSE_MODE 90
#define COMMAND_LINE_FOLLOW_CONFIG 100

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.