Blame ! Saborn for this Thread he pointed out those cheap LCD's on ebay
I just couldn't resist those blue ones lol.
Going to start a project where i can use 1 so it was about time I learnt how to drive it !
seems quick enough dont think i'll need a serial driver again lol.
Ive created a command summary where i can just cut and paste as required
havent tested all of of them yet but think they are correct.
The example program shows how we can display some text
and for fun included a counter so we can see some moving numbers.
The LCD module was a Bona 1602-18 # note the backlight was only 4.2v
I calculated a 10 ohm resistor but best start with something larger.
for contrast Vee i found 1.5k res works well.
Also tested the code on my Sure 4x20 LCD Display, interestingly that display
worked without any connection to vee(contrast).
I just couldn't resist those blue ones lol.
Going to start a project where i can use 1 so it was about time I learnt how to drive it !
seems quick enough dont think i'll need a serial driver again lol.
Code:
'' COMMAND SUMMARY
'senddata = $38 : GOSUB Command '(56) Function 8bit/2line/5x8
'senddata = $01 : GOSUB Command '( 1) Clear Display
'senddata = $02 : GOSUB Command ' '( 2) Cursor Home
'senddata = $07 : GOSUB Command ' '( 7) Character Entry Mode
'senddata = $08 : GOSUB Command ' '( 8) Display Off
'senddata = $0C : GOSUB Command '(12) Display On/Restore Cursor Off
'senddata = $80 : GOSUB Command '(128-147) Line 1 Cursor Position ($80 + 1 to 19)
'senddata = $C0 : GOSUB Command '(192-211) Line 2 Cursor Position ($C0 + 1 to 19)
'senddata = $94 : GOSUB Command '(148-167) Line 3 Cursor Position ($94 + 1 to 19) continuation of line 1
'senddata = $D4 : GOSUB Command '(212-231) Line 4 Cursor Position ($D4 + 1 to 19) continuation of line 2
'senddata = $0D : GOSUB Command ' '(13) Blinking Cursor
'senddata = $0E : GOSUB Command ' '(14) Underline Cursor
'senddata = $10 : GOSUB Command ' '(16) Move Cursor Left
'senddata = $14 : GOSUB Command ' '(20) Move Cursor Right
'senddata = $18 : GOSUB Command ' '(24) Shift Display Left
'senddata = $1C : GOSUB Command ' '(28) Shift Display Right
#picaxe 20X2
#no_data
#terminal off
' DB7 = B.7
' DB6 = B.6
' DB5 = B.5
' DB4 = B.4
' DB3 = B.3
' DB2 = B.2
' DB1 = B.1
' DB0 = B.0
SYMBOL E = C.7
SYMBOL RS = A.0
SYMBOL senddata = b0
SYMBOL index = b1
SYMBOL D1 = b11 'minutes
SYMBOL D2 = b12 'minutes
SYMBOL D3 = b13 'seconds
SYMBOL D4 = b14 'seconds
SYMBOL D5 = b15 'tenths
SYMBOL minutes = w10
SYMBOL seconds = w11
SYMBOL looptime = w12
TABLE 0, ("marks ")
TABLE 16, ("PICAXE 20X2 LCD")
dirsB = %11111111
dirsC = %10111111
Intialise:
FOR index = 0 to 2 ' Initialise LCD
senddata = $38 : GOSUB Command '(56) Function 8bit/2line/5x8
NEXT index
senddata = $0C : GOSUB Command '(12) Display On/Restore Cursor Off
senddata = $01 : GOSUB Command '( 1) Clear Display
CountTIMEofLoop: ' just for fun
SETTIMER 62411
TIMER = 0
Main:
FOR looptime = 1 TO 100
minutes = timer/600
seconds = timer//600/10
bintoascii minutes,D1,D1,D2
bintoascii seconds,D3,D3,D4
D5 = timer//600//10+48
LCDdisplay:
senddata = $80 : GOSUB Command '(128-147) Line 1 Cursor Position ($80 + 1 to 19)
FOR index = 0 TO 6
READTABLE index, senddata : GOSUB Display ' sending characters to line one
NEXT index
FOR index = 0 TO 6
LOOKUP index,(D1,D2,":",D3,D4,32,D5),senddata
GOSUB Display ' sending characters to line one
NEXT index
senddata = 193 : GOSUB Command '(192-211) Line 2 Cursor Position ($C0 + 1 to 19)
FOR index = 16 TO 30
READTABLE index, senddata : GOSUB Display ' sending characters to line two
NEXT index
NEXT looptime : end ' Display time of 100 loops of program (9.8seconds)
Command:
LOW RS ' set to command
outpinsB = senddata ' > send command to LCD
PULSOUT E,1 ' \ valid data failing edge
HIGH RS ' set to character
RETURN
Display:
outpinsB = senddata ' > send character to LCD
PULSOUT E,1 ' \ valid data failing edge
RETURN
havent tested all of of them yet but think they are correct.
The example program shows how we can display some text
and for fun included a counter so we can see some moving numbers.
The LCD module was a Bona 1602-18 # note the backlight was only 4.2v
I calculated a 10 ohm resistor but best start with something larger.
for contrast Vee i found 1.5k res works well.
Also tested the code on my Sure 4x20 LCD Display, interestingly that display
worked without any connection to vee(contrast).
Attachments
-
151.3 KB Views: 808
Last edited: