LCD Demo using ADB40
How to connect my LCD module to the board?
It’s a simple way to connect your 16X2 LCD to ADB40 Board. You do not need cable to connect it to the board, because it’s 16×2 LCD socket already mounted on the board. You need a 1×16 header to solder to the LCD module, or you can see the picture below.
Then install the LCD module to the board, and now you can start to write your code.
The Code???
The code is written in BASIC using BASCOM as compiler. And as you know, BASCOM have some functions to permit you to operate the LCD module easily.
Before we use the function we need to configure the LCD pin connection using the config LCD syntax. (CONFIG LCD = LCD Type, CHIPSET = KS077). Because we are using a 16×2 LCD module, so the code should be like this.
‘——use the 16×2 LCD Display CONFIG LCD = 16*2 |
We are not defining the CHIPSET = KS077 because most text based LCD displays use th same chip from Hitachi. If your LCD modules use the KS077 chipset, you have to define it.
After we define the used of 16×2 LCD Display, now we used to define the LCD pins configuration consider to the board. Please see figure 1 to get pin configuration of LCD Display, the board is not suitable for STK200 LCD pin configuration, so set the value of variables as the pin configuration of figure 1 or you can see this statement.
‘——set the LCD pin configuration. Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portd.6 , Rs = Portd.7 |
That’s all you have to do at the beginning, now lets make our LCD shows your text.
LCD x , X is the variable or constant to display or if prefer to send more variables you just add the “;” separator sign among them. Please see example below.
‘——Shows a text. Cls Locate 1 , 2 Lcd Lowerline Locate 2 , 5 Lcd Wait 3 |
Cls function is used to clear the LCD Display from any text showed. After we clear the screen, place the cursor to the position desire using Locate function. Locate 1,2 syntax will place the cursor to the first row and column 2, otherwise, Locate 2,5 will place the cursor to the second row and column 5 where the first letter of the text start. To shows the text “AVR Development” we use Lcd “AVR Development”.
Wait 3 syntax will delay the process about 3 seconds.
Okay, let’s try to give an animation to our text shown. First we will shift the text to left, the function of Shiftlcd Left will shift one segment/column to left. Because our LCD contains of 16 columns, so we have to shift 16 times to left to shift the all character include the space character.
‘——Shift the text. Sub Geser() For X = 0 To 15 Shiftlcd Left Waitms 100 Next End Sub |
The second animation we’ll make the text blinking. It’s a simple way, you just make the display off and on for 200ms delay among them.
‘——Blink the text. Sub Kedip() For X = 0 To 5 Display Off Waitms 200 Display On Waitms 200 Next End Sub |
And last, if you want to shows your own character to the display, BASCOM has tools to help you to generate the code for you. On the main menu choose Tools>LCD Designer, or press Ctrl+L for keyboard’s shortcut. You’ll see a small window that allow you to design your own character.
If you done, BASCOM will give you a code to form the character that you made like this. Replace the ‘?’ sign with index number from 0 to 7, this special characters can be printed with the Chr( ) function.
‘——LCD Character. Deflcdchar ?,32,10,32,17,14,32,32,32 ‘ replace ? with number (0-7) |
I try to insert a smiley character in the end of demo, just check this code.
‘——Smiley LCD Character. Cls Locate 1 , 21 Lcd “Thank You” Locate 2 , 18 Lcd “Andik Yulianto” Deflcdchar 0 , 32 , 32 , 10 , 32 , 17 , 14 , 32 , 32 ‘ Replace Print With Number(0 -7) “” Locate 1 , 29 Lcd Chr(0) Wait 1 Call Geser Wait 4 |
we can say that, this problem is one logic problem?
is this is true,which part of the nelson logic circute book EXPLANATION this problem?
thank you so much
Well I’m so sorry, I’m not using that book, so i don’t know which part of book that you mean.
hi
if we simulate this program,when program arrive the(shiftlcd left)
line,text disappeared.
how i can RESOLVENT this problem?
Hi Alex,
it depends on from where you place your first character (function –> locate y,x).
For example if you want to shift left the text of “ANDIK” that located on first row, start from second column (locate 1,2) till disappear, you can shift to left of text for >6 times . Illustrated in codes:
cls
locate 1,2
lcd “ANDIK”
For X = 0 To 6 ‘shift 6 times to left
Shiftlcd Left
Waitms 100
Next
I prefer to use 16 times shifting to ensure that the whole text are completely shifted, it was given that the size of our LCD is 2×16 characters (2 rows and 16 columns).
goodluck !!