Graphic LCD (KS0107 driver)

128x64-graphic-Blue-backlight-LCD-module from Sure Electronics on eBay ($20) - white dots on blue

1 VSS 0v 11 D4 B4
2 VDD +5V 12 D5 B5
3 V0 to VOUT 13 D6 D6
4 RS RA1 14 D7 D7
5 R/W RA5 15 CS1 RD0
6 E RC5 16 CS2 RC0
7 D0 B0 17 RST via 10KOhm to +5v
8 D1 B1 18 VOUT to V0
9 D2 B2 19 LED+ via 10 Ohm to +5v
10 D3 B3 20 LED- 0v

NB for best contrast V0 connects directly to VOUT rather than to
the wiper of a pot connected between 0v and VOUT as usual
Remove links to AD potentiometers and remove the LED modules
on Palmelectronics demo board

Graphic LCD

' Graphic_64x128-multitest.bas
' At 20MHz PIC clock the GLcdpset command gives false patterns
' OK at 12MHz and below
AllDigital
PORTA = 0
PORTB = 0
PORTC = 0
PORTD = 0
PORTE = 0
TRISA = 0
TRISB = 0
TRISC = 0
TRISD = 0
TRISE = 0
Define GLCD_DREG = PORTB
Define GLCD_RSREG = PORTA '- defines the port where rs line is connected To
Define GLCD_RSBIT = 1 '- defines the pin where rs line is connected To
Define GLCD_EREG = PORTC '- defines the port where e line is connected To
Define GLCD_EBIT = 5 '- defines the pin where e line is connected To
Define GLCD_RWREG = PORTA '- defines the port where R / W line is connected To
Define GLCD_RWBIT = 5 '- defines the pin where R / W line is connected To
Define GLCD_CS1REG = PORTD '- defines the port where cs1 line is connected To
Define GLCD_CS1BIT = 0 '- defines the pin where cs1 line is connected To
Define GLCD_CS2REG = PORTC '- defines the port where cs2 line is connected To
Define GLCD_CS2BIT = 0 '- defines the pin where cs2 line is connected To
Symbol ltc_cs1 = PORTD.0
Symbol ltc_cs2 = PORTC.0
ltc_cs1 = 1
ltc_cs2 = 1GLcdinitloop:
'--------------------------
'flash all pixels 3 times
GLcdclear 0x00
WaitMs 1000
GLcdclear 0xff
WaitMs 1000
GLcdclear 0x00
WaitMs 1000
GLcdclear 0xff
WaitMs 1000
GLcdclear 0x00
WaitMs 1000
GLcdclear 0xff
WaitMs 1000
GLcdclear 0x00
WaitMs 1000
'--------------------------
' swipe all on
Dim i As Byte
Dim j As Byte
For i = 0 To 127
For j = 0 To 63
'WaitMs 50
GLcdpset i, j
Next j
WaitMs 10
Next i
WaitMs 2000
'--------------------------
'fill with writing
'Dim i As Byte
GLcdclear 0x00
For i = 0 To 15
GLcdposition i, 0
GLcdwrite "Page: ", #i
WaitMs 100
Next i
'--------------------------
' delete in blocks
For i = 0 To 15
GLcdclean i
WaitMs 500
Next i
WaitMs 1000
'--------------------------
' draw two diagonal lines
Dim k As Byte
For j = 0 To 63
GLcdpset j, j
Next j
For j = 0 To 63
k = j + 63
GLcdpset k, j
Next j
WaitMs 1000
Goto loop