LCD Line 2
I have a parallel LCD and i have no idea how to access the second line ![sad.gif](http://forums.parallax.com/images/smilies/sad.gif)
This is my code so far:
I plan to take out all the flashy stuff and have it so the LCD writes to both lines. I am sure the code is there EG
But I don't know how to incorperate it so it actually does what is says :goes to the 2nd line.
If there is ANYTHING you need to know to further aid your assistance please do ask![scool.gif](http://forums.parallax.com/images/smilies/scool.gif)
Microman171
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
Post Edited (Microman171) : 2/26/2006 5:40:21 PM GMT
![sad.gif](http://forums.parallax.com/images/smilies/sad.gif)
This is my code so far:
' ========================================================================= ' ' File....... SW20-EX11-LCD_Demo.BS2 ' Purpose.... Essential LCD control ' Author..... (C) 2000 - 2005, Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... ' Updated.... 01 JUN 2005 ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[noparse][[/noparse] Program Description ]--------------------------------------------- ' ' This program demonstrates essential character LCD control. ' ' The connections for this program conform to the BS2p-family LCDCMD, ' LCDIN, and LCDOUT instructions. Use this program for the BS2, BS2e, ' or BS2sx. There is a separate program for the BS2p, BS2pe, and BS2px. ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- E PIN 1 ' Enable pin RW PIN 2 ' Read/Write RS CON 3 ' Register Select LcdBus VAR OUTB ' 4-bit LCD data bus ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- LcdCls CON $01 ' clear the LCD LcdHome CON $02 ' move cursor home LcdCrsrL CON $10 ' move cursor left LcdCrsrR CON $14 ' move cursor right LcdDispL CON $18 ' shift chars left LcdDispR CON $1C ' shift chars right LcdDDRam CON $80 ' Display Data RAM control LcdCGRam CON $40 ' Character Generator RAM LcdLine1 CON $80 ' DDRAM address of line 1 LcdLine2 CON $C0 ' DDRAM address of line 2 #DEFINE LcdReady = ($STAMP >= BS2P) ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- char VAR Byte ' character sent to LCD idx VAR Byte ' loop counter idx2 VAR Byte ' loop counter2 ' -----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- Msg DATA "Line1", 0 ' store message Msg2 DATA "Line2", 0 ' store message2 ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- Reset: #IF (LcdReady) #THEN #ERROR "Please use BS2p version: SW20-EX11-LCD_Demo.BSP" #ENDIF DIRL = %11111110 ' setup pins for LCD PAUSE 1000 ' let the LCD settle Lcd_Setup: LcdBus = %0011 ' 8-bit mode PULSOUT E, 3 PAUSE 5 PULSOUT E, 3 PULSOUT E, 3 LcdBus = %0010 ' 4-bit mode PULSOUT E, 1 char = %00101000 GOSUB LCD_Cmd char = %00001100 ' disp on, no crsr or blink GOSUB LCD_Cmd char = %00000110 ' inc crsr, no disp shift GOSUB LCD_Cmd ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- Main: char = LcdCls ' clear the LCD GOSUB LCD_Cmd PAUSE 500 idx = Msg ' get EE address of message idx2 = Msg2 ' get EE address of message2 Write_Message: DO READ idx, char ' get character from EE IF (char = 0) THEN EXIT ' if 0, message is complete GOSUB LCD_Out ' write the character idx = idx + 1 ' point to next character LOOP PAUSE 2000 ' wait 2 seconds Write_MessageLine2: DO char = LcdDDRam READ idx, char ' get character from EE IF (char = 0) THEN EXIT char = LcdLine2 ' if 0, message is complete GOSUB LCD_Out ' write the character idx = idx + 1 ' point to next character LOOP PAUSE 2000 ' wait 2 seconds Cursor_Demo: char = LcdHome ' move the cursor home GOSUB LCD_Cmd char = %00001110 ' turn the cursor on GOSUB LCD_Cmd PAUSE 500 char = LcdCrsrR FOR idx = 1 TO 15 ' move cursor l-to-r GOSUB LCD_Cmd PAUSE 150 NEXT FOR idx = 14 TO 0 ' move cursor r-to-l by char = LcdDDRam + idx ' moving to a specific GOSUB LCD_Cmd ' column PAUSE 150 NEXT char = %00001101 ' cursor off, blink on GOSUB LCD_Cmd PAUSE 2000 char = %00001100 ' blink off GOSUB LCD_Cmd Flash_Demo: FOR idx = 1 TO 10 ' flash display char = char ^ %00000100 ' toggle display bit GOSUB LCD_Cmd PAUSE 250 NEXT PAUSE 1000 Shift_Demo: FOR idx = 1 TO 16 ' shift display char = LcdDispR GOSUB LCD_Cmd PAUSE 100 NEXT PAUSE 1000 FOR idx = 1 TO 16 ' shift display back char = LcdDispL GOSUB LCD_Cmd PAUSE 100 NEXT PAUSE 1000 GOTO Main ' do it all over ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- LCD_Cmd: LOW RS ' enter command mode LCD_Out: LcdBus = char.HIGHNIB ' output high nibble PULSOUT E, 3 ' strobe the Enable line LcdBus = char.LOWNIB ' output low nibble PULSOUT E, 3 HIGH RS ' return to character mode RETURN
I plan to take out all the flashy stuff and have it so the LCD writes to both lines. I am sure the code is there EG
char = LcdLine2
But I don't know how to incorperate it so it actually does what is says :goes to the 2nd line.
If there is ANYTHING you need to know to further aid your assistance please do ask
![scool.gif](http://forums.parallax.com/images/smilies/scool.gif)
Microman171
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
Post Edited (Microman171) : 2/26/2006 5:40:21 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
Lcd_Setup:
· LcdBus = %0011······························· ' 8-bit mode
· PULSOUT E, 3
· PAUSE 5
· PULSOUT E, 3
· PULSOUT E, 3
· LcdBus = %0010······························· ' 4-bit mode
· PULSOUT E, 1
· char = %00101000····························· ' multi-line mode
· GOSUB LCD_Cmd
· char = %00001100····························· ' disp on, no crsr or blink
· GOSUB LCD_Cmd
· char = %00000110····························· ' inc crsr, no disp shift
· GOSUB LCD_Cmd
With the proper initialization sequence you can move the LCD to that line with:
· char = LcdLine2
· GOSUB Lcd_Cmd
In short, study Experiment 12 to see how to write to both lines of a 2-line display.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/26/2006 5:47:03 PM GMT
BTW where do I put the LcdLine2 command. A little stuck
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
Post Edited (Microman171) : 2/26/2006 5:53:14 PM GMT
I have the Basic Stamp II educational board and Seetron's BPI-216 LCD.· I don't know what's going on.
Can you help me with this?
Seetron's BPI-216 is a SERIAL LCD, the programming in this thread (Jon's, et al.) concerns parallel LCDs.· You write to your SERIAL LCD using SEROUT instructions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com