In previous articles, we introduced
our CHIPINO module with a pin-compatible layout to the popular
Arduino module (but ours is based
on the Microchip PIC). We also
showed previously how to create
your own shield. Now, we want to
demonstrate a C programming
option that is targeted at the
beginner using the CHIPINO
module. For this demonstration,
we’ll show how easy it can be to
control a 2x16 LCD character
module with a single command
line using the SimpleC library
Chuck Hellebuyck created for his
book Beginner’s Guide to
Embedded C Programming –
Volume 3. With Chuck’s
permission, we’ve included the
SimpleC files with the CHIPINO
A CHIPINO Module and Starter Kit to go with this
article can be purchased online from the
Nuts & Volts Webstore at www.nutsvolts.com
or call our order desk at 800-783-4624.
To demonstrate the simplicity of SimpleC, we’ll do an LCD project. Any SimpleC project requires you to include the simplec.c library file and the simplec.h header file, plus your main.c file which are all based on the Microchip HI-TECH C
compiler you can download for free in lite mode. Because
all the heavy lifting is done in the simplec.c library file, the
main.c file is very short.
The hardware connections for the LCD are defined in
the simplec1.1.h file using the PORTB pins which are pins
8 through 13 on the CHIPINO. These six pins control the
E, RS, and DB4-DB7 pins of the LCD module which is all
you need for four-bit mode operation — the most common
LCD control. The schematic in Figure 1 shows the
connections, and the breadboard layout using a CHIPINO
module is in Figure 2.
The Vo pin of the LCD is grounded, which gives
maximum contrast. On some LCDs, this makes it tough to
read so you may want to add a resistor divider or
potentiometer output on that pin so you can adjust the
voltage and thus the contrast.
Writing ASCII characters to the LCD is useful but
more often you’ll probably want to display a full message
of text. Sending each individual ASCII character could do
this or you could use the lcd_text function in SimpleC.
This project uses that function to display a message on the
first and second line of the 2x16 LCD.
This project creates a message on a 2x16 LCD
module using the lcd_text() function.
PIN 1 - Gnd
PIN 2 - 5v