Shop OBEX P1 Docs P2 Docs Learn Events
16x2 LCD AND STAMP2 — Parallax Forums

16x2 LCD AND STAMP2

Dave55Dave55 Posts: 2
edited 2006-09-09 20:19 in BASIC Stamp
I am working throgh a book "123 Robotics experimente for the elvil genius.
It calls for a 16x2 LCD to attached to the stamp. the LCD lights up, but
that's all.Here is the code I have used any help would be great.

' LCD Test - Display a simple messae ON an LCD module
' {$STAMP BS2}
' {$PBASIC 2.5}
' Variables
i VAR Byte
Character VAR Byte··········· ' Character to Display
LCDData VAR OUT1············· ' Define LCD Pins on BS2
LCDE PIN 8
LCDRW PIN 9
LCDRS PIN 10
' Initialization
DIRS = %11111111111
' Make Least Significant 11 Bits Output
LCDRW = 0: LCDRS = 0: LCDE = 0
' Initialize LCD interface
PAUSE 20
' Wait for LCD to reset itself
LCDData = $0C: PULSOUT LCDE, 300: PAUSE 5
' Initialize LCD Module
PULSOUT LCDE, 300: PULSOUT LCDE, 300
' Forse reset in LCD
LCDData = $1C: PULSOUT LCDE, 300: PAUSE 5
' Initialize/Set 8 Bit
LCDData = $08: PULSOUT LCDE, 300
' No Shifting
LCDData = $80: PULSOUT LCDE, 300: PAUSE 5
' Clear LCD
LCDData = $60: PULSOUT LCDE, 300
' Specify Cursor Move
LCDData = $70: PULSOUT LCDE, 300
' Enable Display & Cursor
Character = 1: i = 0
LCDRS = 1··················· ' Print Character
DO WHILE (Character <> 0)
· LOOKUP i, [noparse][[/noparse]"Evil Genius", 0], Character
· IF (Character <> 0) THEN
··· LCDData = Character REV 8: PULSOUT LCDE, 300
··· i = i + 1
··· ENDIF
· LOOP
· END

Comments

  • ForrestForrest Posts: 1,341
    edited 2006-09-09 17:20
    Did you try adjusting the potentiometer?

    I checked your program for typing accuracy and didn't see any mistakes - but that doesn't mean there wasn't a problem with the original program.

    There are many ways to connect a parallel LCD to a BS2 - and I don't really like the method Myke Predko uses in his book because it uses 8-bit mode and wastes a lot of pins in my opinion.

    For instructions on how to connect in 4-bit mode along with a BS2 program, check out Nuts & Volts #31 which you can get here www.parallax.com/html_pages/downloads/nvcolumns/Nuts_Volts_Download_V1.asp
  • Dave55Dave55 Posts: 2
    edited 2006-09-09 19:11
    Thanks I will take a look.
  • vaclav_salvaclav_sal Posts: 451
    edited 2006-09-09 20:10
    I did not read your code but would suggest to you to·check Hitachi's HD44780U app note.
    (Sorry I do not have the link handy - just Google it).
    The LDC controller needs proper initialization if not used in 8 bit mode.
    You said·you are· using it in "parallel" mode and I am assuming that means 8 bit mode in controller terminology.


    Anyway, check the app note - especially the "extrernal initialization" ( I think fig 21 / 23).

    Pay attention to timing and switching from data to control mode.

    I have a working 4 bit code I could send you if you are interested.
    ·
  • vaclav_salvaclav_sal Posts: 451
    edited 2006-09-09 20:19
    Just noticed that you are using OUT1!
    You need to send either 8 bits OUTL / OUTH or 4 OUTA - OUTC
Sign In or Register to comment.