Go Down

Topic: Serial 20x4 LCD board (Read 1 time) previous topic - next topic

squartochi

Hi, I have a Serial LCD board http://www.nkcelectronics.com/serial-20x4-lcd-bo204.html  I can use the example code. But I can't really figure out how to use this in other applications. I am using it with a 20x4 WH2004A-TMI-JT#. Has anyone used this?
Thanks

PaulS

When you ran the sample code, did the text show up on the LCD?

squartochi

Yes, but when I compare the code to other similar applications it does not make sense to me. Sorry but I am very green when it comes to programming. I have been trying to learn as much as possible. Thanks to all.

quadmasta

What doesn't make sense about their sample program?

PaulS

Is this the code that you uploaded:

Code: [Select]
// Serial LCD sample program
// NKC Electronics
void setup()
{
Serial.begin(9600);
// Display ON
Serial.print(0xfe, BYTE);
Serial.print(0x41, BYTE);
// Backlight ON
Serial.print(0xfe, BYTE);
Serial.print(0x52, BYTE);
// Home Cursor
Serial.print(0xfe, BYTE);
Serial.print(0x46, BYTE);
// Send some text
Serial.print("NKC Electronics");
// Cursor to column 1, line 2
Serial.print(0xfe, BYTE);
Serial.print(0x45, BYTE);
Serial.print(0x01, BYTE);
Serial.print(0x02, BYTE);
// Send some more text
Serial.print("SerialLCD module");
}
void loop()
{
}


If so, it's pretty straightforward. You use Serial.print to send data to the LCD's on-board controller. Some of the data is interpreted by the controller (anything following a 0xfe). There are 1, 2, and 3 byte commands. Some turn the LCD on. Some turn the back-light on. Some position the cursor.

Anything that is not preceded by 0xfe is assumed to be text to be displayed, starting at the current cursor position and proceeding to the end of the row. The text then wraps to the beginning of the next line.

squartochi

Thanks so much. Maybe I am not even ready to ask questions yet. ;D

tkbyd

"Divide and conquer" is the route to progress.

Put the things you want to do in functions.

Test what you are trying to do a bit at a time. ISOLATE the problem areas.

Often it helps to create substitutes for bits of the project while you get the OTHER bits working. Suppose you were working on an alarm system. At first, just use a push button for the signal from the motion detector. When everything else is working, replace the push button with the real detector. Works? Good! Doesn't work the way it did with the push button? Must be something to do with how the sensor is connected.

floresta

squartochi:

Quote
Yes, but when I compare the code to other similar applications it does not make sense to me.

Download the Longtech datasheet from the link in your original post.  Scroll down to page 7 where the 'Advanced operation commands' start.  The first entry in that page is:
Turn On Display
Syntax hexadecimal 0xFE 0x41


Compare that to this code in reply #4:
// Display ON
Serial.print(0xfe, BYTE);
Serial.print(0x41, BYTE);


Does this help?

Don

squartochi

Yes, Thanks again. I now understand the sample code. :)

Go Up