I use the example to show 10-14 kids how it easy and your code is to big for those kids (-:
I must not use so much code and use only\ more graphical.
So you're teaching your pupils how to drive a parallel LCD with a PICAXE and they can't comprehend the code.
1. I'll break my code down into subsections to see if it is clearer - the lookups don't
have to be used.
This is the symbols definitions which apply alias names to variables and pins in order to make the pin functions memorable and to allow fast changing of pins if desired by simply changing the pin numbers. It is put at the beginning of the code.
Code:
symbol rs = C.1'whatever pin you want
symbol enable = C.0'whatever pin you want
symbol lcddata = pinsB
symbol loopcounter = b27
symbol readvar = b26
This sets portB and the pins defined for rs and enable to outputs. It only needs to be done once on power-on.
Code:
dirsB = 255
low rs
output enable
This bit initiaizes the LCD display. It only needs to be done once per power-up. It is also compatible with the Winstar OLED displays sold at Techsupplies in case you want to upgrade.
Code:
lcddata = 000110 : pulsout enable,100
lcddata = 001100 : pulsout enable,100
lcddata = 111011 : pulsout enable,100
lcddata = 000001 : pulsout enable,100
To send an
instruction to the LCD simply use this ('low rs' can be removed if it is already low). Instructions used after initialization will be mainly just to set the location to print the text on the LCD so 128 is the beginning of line 1 and 192 is the beginning of line 2.
Code:
low rs
lcddata = [I]instruction[/I] : pulsout enable,1
To send a
data byte to the LCD simply use this. Data will be loaded into the LCD SRAM location that was set by an instruction so a data byte could be a character to appear on the LCD or data to define parts of the CGRAM.
Code:
high rs
lcddata = [I]data[/I] : pulsout enable,1
If you only have a small amount of consecutive data bytes to send then multiple instances of the above ('high rs' doesn't need to be repeated) can be sent but if you have a lot of data to send then you might prefer to use a loop. In this example, the loop sends the
data in the brackets to the LCD. The number that follows 'for loopcounter = 0 to ' is the number of bytes minus one.
Code:
low rs
lcddata = 192: pulsout enable,1
high rs
for loopcounter = 0 to 15
lookup loopcounter,("16 CHARS LINE 2 "),readvar
lcddata = readvar
pulsout enable,1
next loopcounter
2. You can replicate the function of the code with flowchart symbols however it could look messy.