Interfacing LCD display with arduino duemilanove

Hello,

How do I interface a LK202-25 LCD with an Arduino?

I am a noob at programming microcontrollers, and from my understanding, the LCD can display the print commands if connected to the computer using the cable with the pins for RS and RW. I have tried just connecting the LCD to the arduino, but to no avail, as a stream of gibberish appeared.

This could also be due to the fact that I dont have the proper library installed. The lcd.print() function doesnt work because I dont have the LCD4Bit_mod.h library/drive/directory ... thing.

Any help would be greatly appreciated.

Thanks!

The Matrix Orbital LK202-25 is a serial display and may be used with RS232, I2C or TTL depending on which way the solder jumpers are set. To use it it with RS232 you need a line driver like the MAX232 or MAX233 to handle the 5v/12v inverted signal issue.

I have the LK204-25-WB and choose to use a MAX233 chip rather than switching the jumpers because I also want the option of directly connecting it to a PC serial port. Make sure you set the right baud rate too. I use the NewSoftSerial library to control the LCD.

Here is a link to the manual http://www.matrixorbital.ca/manuals/LK_series/LK202-25/LK202-25_112.pdf

Sample code for four line display:

// Arduino and LCD setup 
#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);

void setup()  
{
  // set the data rate for the NewSoftSerial port
  mySerial.begin(9600);
   delay(2000);
  AutoWrapOn();
  AutoScrollOff();
  BackLightOn(0);
  ClearLCD();
//  Contrast(128);
//  Brightness(128);
  mySerial.println("Hello, world?");
}


//  MAIN CODE

void loop()
{ 
  //backlightOn(0);  // turn the backlight on all the time
//  if (mySerial.available()) {

  ClearLCD();
  Brightness(64);
  delay(2000);
  CursorPos(3, 2);
  mySerial.print("Test line 1");  // print text to the current cursor position
//  BackLightOff();

  delay(2000);
  Brightness(128);
  CursorPos(3, 3);
  mySerial.print("Test line 2");  // print text to the current cursor position
  delay(2000);
}




//  LCD  FUNCTIONS-- keep the ones you need. 

// clear the LCD
void ClearLCD(){
  mySerial.print(254, BYTE);
  mySerial.print(88, BYTE);
}

// start a new line
void newLine() { 
  mySerial.print(10, BYTE); 
}

// move the cursor to the home position
void cursorHome(){
  mySerial.print(254, BYTE);
  mySerial.print(72, BYTE);
}

// move the cursor to a specific place
// e.g.: cursorSet(3,2) sets the cursor to col 3 and row 2
void CursorPos(int xpos, int ypos){  
  mySerial.print(254, BYTE);
  mySerial.print(71, BYTE);               
  mySerial.print(xpos, BYTE);   //Column position   
  mySerial.print(ypos, BYTE);   //Row position 
} 


// move cursor left
void cursorLeft(){    
  mySerial.print(254, BYTE); 
  mySerial.print(76, BYTE);   
}

// move cursor right
void cursorRight(){
  mySerial.print(254, BYTE); 
  mySerial.print(77, BYTE);   
}

// turn on backlight
void BackLightOn(int mins){
      mySerial.print(254, BYTE);
      mySerial.print(66, BYTE);   
      mySerial.print(mins, BYTE);         // use 0 minutes to turn the backlight on indefinitely   
}

// Set contrast level
void Contrast(int value){
      mySerial.print(254, BYTE);
      mySerial.print(80, BYTE);   
      mySerial.print(value, BYTE);         // 0 to 255
}

// Set brightness
void Brightness(int value){
      mySerial.print(254, BYTE);
      mySerial.print(153, BYTE);   
      mySerial.print(value, BYTE);         // 0 to 255
}

// turn off backlight
void BackLightOff(){
      mySerial.print(254, BYTE);
      mySerial.print(70, BYTE);   
}

//       Turn Auto scroll ON
void AutoScrollOn(){
       mySerial.print(254, BYTE);
       mySerial.print(81, BYTE);     
}         
       
//       Turn Auto scroll OFF
void AutoScrollOff(){
       mySerial.print(254, BYTE);
       mySerial.print(82, BYTE); 
}         

//       Turn ON AUTO line wrap
void AutoWrapOn(){
       mySerial.print(254, BYTE); 
       mySerial.print(67, BYTE);              
}

//       Turn OFF AUTO line wrap
void AutoWrapOff(){
       mySerial.print(254, BYTE); 
       mySerial.print(68, BYTE); 
}

//       Turn OFF the block cursor    
void BlockCursorOff(){
         mySerial.print(254, BYTE);
         mySerial.print(84, BYTE);               
}

//       Turn ON the block cursor
void BlockCursorOn(){
       mySerial.print(254, BYTE);
       mySerial.print(83, BYTE);  
}

//       Turn ON the underline cursor
void ULCursorOn(){
       mySerial.print(254, BYTE);
       mySerial.print(74, BYTE);               
}

//       Turn OFF the underline cursor
void ULCursorOff(){
       mySerial.print(254, BYTE);
       mySerial.print(75, BYTE);               
}

Thanks for the reply Ron!

I understand slightly more about whats going on now, but the code you gave me doesn't work, to an extent: the characters are garbled, but they repeat, so i know the loop function is working. On the LCD, the manufacturer provided it with the TTL jumpers connected (which is nice, since I dont want to worry about buying the MAX232 line driver to invert the signal)

Would the code work with TTL? Or is it different? Still struggling to get a basic LCD setup to work with the arduino ... :-[

Looks like your LCD may not work with TTL based on this info from page 2 of the manual:

DB9 Connector Pin Out RS - 232 port: This connector is wired so that a standard “straight through” 9 pin D-sub cable may be used to connect the modules on a standard serial port such as comm ports on PCs. Note that this device complies to the EIA232 standard in that it uses signal levels from +/- 3V to +/- 12V. It will not operate correctly at TTL (0 to +5V) levels.

You might try I2C connectrion using the Wire library.