Beginner’s Guide to Programming: Lesson 3
• LCDcontrol
Sends a special control
code to the LCD
FIGURE 9
1 – Clear the Display
2 – Home the Display
12 – Cursor Off
14 – Cursor On, No Blink
15 – Cursor On, Blink
16 – Shift Cursor Left
20 – Shift Cursor Right
24 – Shift Display Left
28 – Shift Display Right
simulation form as shown in Figure 10.
Once selected, a 16 x 2 character
LCD will pop up as shown in Figure 11.
This LCD is a very close simulation of
a 16 x 2 LCD using a Hitachi 44780
controller. The memory mapping and
control characters are all supported.
To use the LCD commands, you
must first use the LCDinit command.
This properly initializes the LCD. Once
initialized, you have three commands
that can be used to send data to the LCD:
• LCDwrite
Sends a string of characters to the LCD
To send a simple message to the
LCD, you use the LCDwrite command
as shown in Figure 12. This will display
the message shown in Figure 13.
We can scroll the LCD display to the
right then back to the left by utilizing a
couple control codes. Load and run the
code in Figure 14 to see the effect.
guage, you have
access to variable
arrays. While the
Athena Simulator
does not have
access to such variables, it does have a
couple of commands that will let
FIGURE 8 you access declared
variables as a group.
When you create variables in your
code, they are stored in contiguous
locations in memory. When you use
the Dim command to create the
variables a, b, c, d, and e, they are each
stored in memory, one after another.
The ArrayGet and ArraySet commands
take advantage of this and let you
access the variables by using only the
first variable as a reference.
The code in Figure 15 is using the
ArraySet Command to set the variables
a, b, c, d, and e to a value of 55. The
first argument is the reference variable.
This is the first variable in the list that
you wish to manipulate. The second
argument is the index. If the value of
this index is 0, then the variable a will
be accessed. If the value is 1, then the
variable b is accessed, and so on.
The ArrayGet works much the
same way as the ArraySet command.
Instead of passing a value to set, we
pass a variable that will hold the result
of the indexed variable.
• LCDchar
Sends a single character to the LCD
ArrayGet and
ArraySet Commands
Programming a
Real Athena
FIGURE 10
In more advanced
dialects of the Basic lan-
FIGURE 11
This month, we complete our final
lesson. The next logical step is to
actually program a microcontroller. The
Athena line of microcontrollers was
created for the sole purpose of getting
you started programming a microcontroller. The Athena microcontroller shown in Figure 17 is a
perfect device to start with.
Kronos Robotics sells them
for $6.95 each. The Perseus
FIGURE 13
FIGURE 12
48 SERVO 09.2007