• UP Pin 13 (PD7)
• CTR Pin 14 (PB0)
• DWN Pin 16 (PB2)
• RGT Pin 15 (PB1)
Navigator Buttons:
Software
■ FIGURE 8. BreadboArduino basic wiring.
Whether you choose to
build this project for an Arduino
board or the BreadboArduino or
any other AVR development
board, you’ll want to first test it
with the nav_buttons tester
software. When you run this
code, the first message output is
“NavButt.” (I wasn’t trying to be
funny; it’s just that with only
eight characters and two lines
we have to be parsimonious
with our text.) This is followed
shortly by the revision number,
then the screen blanks and waits
for you to press a button.
Figure 6 shows the message that
is printed if you press the center
button: CTR!
The program spins in a
forever loop - for(;;) checking the
nav_available() function to see if —
well, can you guess? Right. It
returns 0 if no button has been
pressed and not 0 if a button has
been pressed. The ‘not 0’ is a
number that has a bit for each
button press identified. We
assume that there will generally
only be one bit set but you
might get several pressed at the
same time, so the code
processes the bits sequentially
setting each bit back to 0 when it
has been handled until all the bits
are set back to 0. As you will see
shortly, this sequential processing
gives you the opportunity to
prioritize the key presses so that,
for instance, the CTR key will
always be processed before any
other key.
■ FIGURE 9. LCDNAV wired to BreadboArduino.
The Navigator Library
62
• E
• RW
• RS
• LFT
February 2012
Pin 17 (PB3)
GND
Pin 18 (PB4)
Pin 12 (PD6)
The Navigator library consists of nav.c and nav.h
which exposes a few simple functions:
void nav_init(); // initialize the navigator