LCD Demo using ADB40
Posted by Andik on October 21, 2008
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 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.
Locate 1 , 2
Locate 2 , 5
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.
For X = 0 To 15
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.
For X = 0 To 5
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.
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.
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