To learn more about how to control a 44780 based LCD, go here first so that you get an understanding of how to control this module.
In the meantime, here are three solutions for controlling a 44780 based module with a Parallax BS2.
Each program displays the message "Lennard Electronics www.lennard.net.nz" on the LCD.
Notes: I have used a 2 x 20 LCD. If you are using a 2 x 16 LCD, you will need to make a few minor changes to the code. Also, regarding the contrast pin (pin 3). The easiest thing to do, is to ground pin 3. Of course, you will not have control over contrast (you'll get full contrast), but it will get you started quicker. Details on contrast adjustment can be found on the page linked to above.
To save Microcontroller pins:
-or-
-or-
|
'{$stamp BS2} '[DECLARE VARIABLES] StartScreen
DATA "Lennard Electronics www.lennard.net.nz" 'Writes this to EEPROM '[MAIN CODE
BEGINS] '[END MAIN CODE] '[ROUTINES] resetcmos:
'Reset
the 4094 setuplcd: 'Now, setup the LCD DisplayStartupMessage: newline: 'Start on next line sendtoLCD:
ClearDisplay: cursor: |

For more information on how to implement I2C, go here.
Click here for an example of how to drive a Matrix Orbital LCD display with built in I2C support.
Notes: the resistors are needed. The outputs of all I2C devices are open drain, so the 10k resistors are needed as pull up resistors. As the Stamp has totem pole outputs, there is a slight chance that a bus short could occur when being used with I2C, so the two 220 ohm resistors limit the current if that were to happen (example, if the I2C device pulled SDA low when the Stamp was outputing a High.
|
'{$STAMP BS2} 'I2C test program.
4/9/2002 Ben Lennard 'STAMP EEPROM
DATA
'VARIABLES
DIRS=%1111111111111111 'MAIN CODE '[SUBROUTINES] '************************
LCD SOUBROUTINES ******************************** LCD_Command:
sendtoLCD:
ClearDisplay: newline:
'***********************
I2C SUBROUTINES ********************************** 'Stop Procedure.
Set stop condition on bus: SDA Lo-Hi while SCL Hi 'Write Address/Data
Procedure DisplayStartupMessage:
' "Lennard
Electronics " ReadEEPROM: '[END OF SUBROUTINES] |
|
'{$stamp BS2} '[DECLARE VARIABLES] StartScreen
DATA "Lennard Electronics www.lennard.net.nz" RS CON 8 ' Port 8, Low = Instruction to the LCD, High
= Data to the LCD '[MAIN CODE
BEGINS] '[ROUTINES] DisplayStartupMessage: newline: sendtoLCD:
ClearDisplay: cursor: '[END OF ROUTINES] |