lcd touch panel suppliers
AllDigital
Config PORTC = Output
configuration:
Symbol enablepin = PORTC.0
Symbol clockpin = PORTC.1
Symbol datapin = PORTC.2
declarations:
Dim i As Byte
Dim lcdi As Byte
Dim lcdbyte As Byte
Dim lcdbytetosend As Byte
Dim rs As Bit
Dim flag As Byte
Dim mask As Byte
init:
Gosub initialiselcd
loop:
lcdbytetosend = 32
Gosub writelcddata
lcdbytetosend = “H”
Gosub writelcddata
lcdbytetosend = “e”
Gosub writelcddata
lcdbytetosend = “l”
Gosub writelcddata
lcdbytetosend = “l”
Gosub writelcddata
lcdbytetosend = “o”
Gosub writelcddata
lcdbytetosend = 32
Gosub writelcddata
lcdbytetosend = “W”
Gosub writelcddata
lcdbytetosend = “o”
Gosub writelcddata
lcdbytetosend = “r”
Gosub writelcddata
lcdbytetosend = “l”
Gosub writelcddata
lcdbytetosend = “d”
Gosub writelcddata
lcdbytetosend = “!”
Gosub writelcddata
WaitMs 4000
lcdbytetosend = 0x01 ‘clear screen
Gosub writelcdcommand
WaitMs 2000
Goto loop
End
writelcdnibble:
Low enablepin
Low clockpin
If rs = 1 Then High datapin Else Low datapin
Gosub toggleclockpin
‘shift in 4 bits
mask = 8
For lcdi = 1 To 4
flag = lcdbyte And mask
If flag = 0 Then Low datapin Else High datapin
Gosub toggleclockpin
mask = ShiftRight(mask, 1)
Next lcdi
‘now strobe the clock one more time because ST+SC are tied
Gosub toggleclockpin
‘toggle the enable pin to “flush” the data into the lcd
Low datapin
High enablepin
Low enablepin
Return
toggleclockpin:
‘toggle the clock pin
High clockpin
Low clockpin
Return
writelcddata:
rs = 1
Gosub senddata
Return
writelcdcommand:
rs = 0
Gosub senddata
Return
senddata:
lcdbyte = ShiftRight(lcdbytetosend, 4)
Gosub writelcdnibble
lcdbyte = lcdbytetosend And 15
Gosub writelcdnibble
Return
initialiselcd:
For i = 1 To 3
WaitMs 50
lcdbytetosend = 0x20
Gosub writelcdcommand
Next i
WaitMs 50
lcdbytetosend = 0x28 ‘4 bits, 2 lines, 5×7 font
Gosub writelcdcommand
WaitMs 50
lcdbytetosend = 0x0c ‘display on, no cursors
Gosub writelcdcommand
WaitMs 50
lcdbytetosend = 0x06 ‘entry mode auto-increment
Gosub writelcdcommand
WaitMs 50
lcdbytetosend = 0x01 ‘clear screen
Gosub writelcdcommand
Return
best results