Page 223 - The Ultimate Palm Robot
P. 223
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 8
206 The Ultimate Palm Robot
Following the comment lines in the source file are some include statements:
#include <aCore.tea>
#include <aPPRK.tea>
#include <aA2D.tea>
These three files are part of the library that comes with the Acroname soft-
ware. The aCore file contains functions and subroutines for sending data to and
from the ports, and it contains a subroutine, aCore_Sleep( ), that pauses the
program. The aPPRK file contains a single routine for commanding the servos.
The file aA2D contains two functions that read data from the analog ports of the
BrainStem. Finally, both aCore and aA2D include the file aIOPorts, which de-
fines constants that can be used in the TEA programs. The include statements
are followed by some constant definitions:
#define SPEEDR 100
#define SPEEDL 100
#define DRANGE 175
These lines define three constants that will be used in the code that follows.
Using constants is better than using the literal numbers in your code. It makes
the code easier to understand because anyone reading the code can make a
good guess about what SPEEDR refers to, but guessing what 100 refers to
would be much more difficult.
Next, we get to the starting point for the program. Each program you create
and run must have one and only one main( ) function. The code for chase.tea
uses void main( ), but recall that main( ) can return char or int, and take pa-
rameters. The main( ) function is the function that the TEA VM calls to begin
execution of your program.
void main()
{
Next, the program defines a number of variables:
int b;
int r1;
P:\010Comp\Bots\880-6\ch08.vp
Monday, May 12, 2003 1:16:45 PM