This line declares the
turn()
function without actually including a copy of its code. To access the
declaration, each C file that needs to call
turn()
adds the following line:
Note the double-quotes being used instead of angle brackets. This signifies to the C compiler that
the header file is in the project directory, rather than being a system header file like
3pi.h
. Always
remember to put the code for your functions in the C file instead of the header file! If you do it the other
way, you will be making a separate copy of the code in each file that includes the header.
The file
follow-segment.c
also contains a single function,
follow_segment()
, which will drive 3pi
straight along a line segment until it reaches an intersection or the end of the line. This is almost the
same as the line following code discussed in
, but with extra checks for intersections and
the ends of lines. Here is the function:
1
#include "turn.h"
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
8. Example Project #2: Maze Solving
Page 39 of 85
Содержание 0J5840
Страница 24: ...Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 5 How Your 3pi Works Page 24 of 85...
Страница 67: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 67 of 85...
Страница 77: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 77 of 85...