M a r k   C r o s b i e

You are in: STAMP Serial LCD  Home  Resume  Linux  LEGO  Electronics  Movies  Mac OS X 


Details
Overview Simple buzzer LCD control Buzzer and LCD PWM motor control Stepper motor control
Contact Mark at mark@mastincrosbie.com

STAMP Serial LCD

This is a short description of how to interface to an LCD module that you can buy from Scott Edwards Electronics. The LCD modules available from him are self-contained and only require 3 lines to work: 5V power, ground and a serial input line! It couldn't be any easier.

The screen sizes are either 2 or 4 lines; I bought a 2 line module. It is very handy for debugging projects on the fly where you need to continually monitor a value, but don't want the expense of sending debug messages to your PC. However, you will note a small slowdown of your code as the Stamp sends data to the LCD module.

The LCD receives commands over the serial line that you send using the SEROUT command. The LCD runs at either 9600 baud or 2400 baud. If you are using a Stamp 1 then you will be limited to 2400 baud communication. The Stamp2 will communicate at 9600 baud with the LCD. I recommend this as the slower baud rates will slow down the execution of your code.

Sample code to send data to a LCD

Here is some Basic 2 code to send data to the LCD module. You notice that I use lots of constant definitions to encode commands to the module.

If you want to send data at 9600 baud to the LCD module, replace the
N24N    con   16780
definition with
N96N    con     16468


Whereever I use N24N in the code, you replace that with N96N and don't forget to set your LCD module to 9600 baud!

Click here to download the PBASIC code.

'
' lcd.bs2
' Send "hello world" to a Serial LCD connected to 
' P9 (pin 14) of a STAMP II
'
' Mark Crosbie 1998  mark@mastincrosbie.com
'
LCDPREFIX	con	254
LCDCLS	con	1
LCDHOME	con	2
LCDBLANK	con	8
LCDSCRLLEFT	con	24
LCDSCRLRT	con	28
N24N	con	16780

dir9 = 1
serout 9,N24N,[LCDPREFIX, LCDCLS]
serout 9,N24N,["Hello"]
serout 9,N24N,[" THERE"]
pause 5000

for b1 = 1 to 10
serout 9,N24N,[LCDPREFIX, LCDSCRLLEFT]
pause 100
next
Ok, what does it do? It prints Hello THERE on the LCD screen and then scrolls it left ten times. Silly, but it illustrates the point. The commands to clear the screen (LCDCLS) and scroll the screen (LCDSCRLLEFT) are constants obtained from the manual that came with the LCD backpack.


 
cover
PIC Microcontroller Project Book
Lot's of great PIC project ideas!
cover

Programming and Customizing the Pic Microcontroller

If you are learning to program microcontrollers then Myke's book is good start.
cover
The Art of Electronics
A classic in the field. Teaches you the art and science of linear and digital electronic design. If you want to learn why your circuit is not working, read this book and you'll know why.
cover
Mobile Robots: Inspiration to Implementation
A very readable introduction to the art of robotic design and implementation from the best practioners in the field: the MIT Artificial Intelligence Lab!
cover
Microcontroller Cookbook
A set of cookbook style designs for the 8051 and PIC microcontrollers. A handy reference to have if you need a quick solution to a problem.

© 2002-2004 Mark Crosbie   shareright © 2002 Phlash