1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* 3pi-linefollower - demo code for the Pololu 3pi Robot
*
* This code will follow a black line on a white background, using a
* very simple algorithm.
It demonstrates auto-calibration and use of
* the 3pi IR sensors, motor control, bar graphs using custom
* characters, and music playback, making it a good starting point for
* developing your own more competitive line follower.
*
*
http://www.pololu.com/docs/0J21
*
*
*
*/
// The 3pi include file must be at the beginning of any program that
// uses the Pololu AVR library and 3pi.
#include <pololu/3pi.h>
// This include file allows data to be stored in program space.
The
// ATmegaxx8 has 16x more program space than RAM, so large
// pieces of static data should be stored in program space.
#include <avr/pgmspace.h>
// Introductory messages.
The "PROGMEM" identifier causes the data to
// go into program space.
const
char
welcome_line1[] PROGMEM =
" Pololu"
;
const
char
welcome_line2[] PROGMEM =
"3\xf7 Robot"
;
const
char
demo_name_line1[] PROGMEM =
"Line"
;
const
char
demo_name_line2[] PROGMEM =
"follower"
;
// A couple of simple tunes, stored in program space.
const
char
welcome[] PROGMEM =
">g32>>c32"
;
const
char
go[] PROGMEM =
"L16 cdegreg4"
;
// Data for generating the characters used in load_custom_characters
// and display_readings.
By reading levels[] starting at various
// offsets, we can generate all of the 7 extra characters needed for a
// bargraph.
This is also stored in program space.
const
char
levels[] PROGMEM = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
// This function loads custom characters into the LCD.
Up to 8
// characters can be loaded; we use them for 7 levels of a bar graph.
void
load_custom_characters()
{
lcd_load_custom_character(0,0);
// no offset, e.g. one bar
lcd_load_custom_character(1,1);
// two bars
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
7. Example Project #1: Line Following
Page 31 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...