Serial LCD Sample code

Everything Arduino - Arduino is an exciting and fun open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Serial LCD Sample code

Postby willp » June 12th, 2008, 1:02 am

Here is a quick sample showing the use of the Serial LCD in I2C mode with the Arduino.

The biggest catch is the Wiring library requiring the I2c device to be in 7bit mode (shifted left by one) since it does an auto shift right and appends the 1 or 0 depending on if it is reading or writing to the I2c bus.

Code: Select all
/* Quick example to use FunGizmos serial LCD in I2C mode
*
* Connections between LCD & Arduino 
* LCD P2
*   Pin1 not connected
*   Pin2 not connected
*   Pin3 SCL -> Analog in 5 (Arduino has internal pullup resistor)
*   Pin4 SDA -> Analog in 4 (Arduino has internal pullup resistor)
*   Pin5 VSS -> gnd
*   Pin6 VDD -> +5V
*
* To enable I2C mode of LCD Pads of R1 must be jumpered on back of LCD (Between R6 & R14 right below the black IC glob)
*
*/

#include <Wire.h>

int lcd_addr = 0x50; //default I2C hex address from datasheet
int blink;

void setup(){
  delay(1000); //allow lcd to wake up.
 
  Wire.begin(); //initialize Wire library
 
  // Wire library expects 7-bit value for address and shifts left appending 0 or 1 for read/write
  // Lets adjust our address to match what Wire is expecting (shift it right one bit)
  lcd_addr = lcd_addr >> 1;
 
  //Send lcd clear command
  Wire.beginTransmission(lcd_addr);
  Wire.send(0xFE); //Cmd char
  Wire.send(0x51); //Home and clear
  Wire.endTransmission();
 
  Wire.beginTransmission(lcd_addr);
  Wire.send(0xFE); //Cmd char
  Wire.send(0x70); //Display LCD firmware version
  Wire.endTransmission();
 
  delay(2000);
 
  //Send lcd clear command
  Wire.beginTransmission(lcd_addr);
  Wire.send(0xFE); //Cmd char
  Wire.send(0x51); //Home and clear
  Wire.endTransmission();
 
  Wire.beginTransmission(lcd_addr);
  Wire.send("Hi I'm using I2C");
  Wire.endTransmission();
   
  Wire.beginTransmission(lcd_addr);
  Wire.send(0xFE); //Cmd char
  Wire.send(0x45); //Set Cursor pos
  Wire.send(0x40); //Line 2
  Wire.endTransmission();
   
  Wire.beginTransmission(lcd_addr);
  Wire.send("FunGizmos.com");
  Wire.endTransmission();

}



void loop(){
   
    Wire.beginTransmission(lcd_addr);
    Wire.send(0xFE); //Cmd char
    Wire.send(0x45); //Set Cursor pos
    Wire.send(0x40+15); //Line 2 last char
    Wire.endTransmission();
   
    Wire.beginTransmission(lcd_addr);
    if(blink)
       Wire.send('*');
    else
       Wire.send(' ');
    Wire.endTransmission();
    blink = !blink;
   
  delay(500);
}
www.FunGizmos.com
willp
Site Admin
 
Posts: 19
Joined: February 4th, 2008, 1:21 am
Location: Woodland, WA

Re: Serial LCD Sample code

Postby jm_arduino » June 15th, 2008, 7:49 pm

Will,

Thanks again for posting the sample code. I modified it and got a test count loop up and running in I2C mode!!! :D

Soldering the jumper wire was more challenging then I expected. I need to get a smaller soldering iron tip. Here are the pictures I took and a short video.

Regards,

Jeff

Image
Image
Image

Brief You Tube Video http://www.youtube.com/watch?v=JY_0inWEXhs
jm_arduino
 
Posts: 4
Joined: June 15th, 2008, 7:36 pm

Re: Serial LCD Sample code

Postby tempalte » July 23rd, 2008, 10:43 pm

Anyone have code to make text scroll across the top line?

If I just have the display shift left, it wraps to the second line, then back to the first line.
tempalte
 
Posts: 1
Joined: July 23rd, 2008, 9:01 pm

Re: Serial LCD Sample code

Postby willp » August 6th, 2008, 2:40 pm

tempalte wrote:Anyone have code to make text scroll across the top line?

If I just have the display shift left, it wraps to the second line, then back to the first line.


Hi,

Since that doesn't appear to be built into the LCD firmware the easiest would be to create your own scroll function that when called would send a text string containing the whole top row. Each time you call it it could you could shift or index into the string one char. Depending on what you want you could either discard or make it wrap.

This semiphore project by Chad Phillips does something similar you could start with. http://www.windmeadow.com/node/55
www.FunGizmos.com
willp
Site Admin
 
Posts: 19
Joined: February 4th, 2008, 1:21 am
Location: Woodland, WA

Re: Serial LCD Sample code

Postby evilc66 » October 30th, 2008, 8:18 am

Need a little help. I'm new to working with micros, and have a Arduino Decimelia that I have been working with for a little while now. I just got your serial LCD, and I was trying to hook it up using the RS232/TTL connection. I tried using the sample code that Arduino.cc has posted that can be found here, but with no luck. Is the command codes for I2C the same as TTL serial? I thought I may need to change values set in the sample code to match the datasheet, but I'm not too sure. Any advice?
evilc66
 
Posts: 2
Joined: October 30th, 2008, 8:11 am

Re: Serial LCD Sample code

Postby evilc66 » October 30th, 2008, 6:22 pm

Nevermind. Turns out I wasn't paying attention and forgot to change the baud rate.

I do still have one question though. Is there a command for a new line (carriage return), or do I have to specify the cursor position for the begining of the next line?
evilc66
 
Posts: 2
Joined: October 30th, 2008, 8:11 am

Re: Serial LCD Sample code

Postby willp » November 24th, 2008, 3:02 am

evilc66 wrote:I do still have one question though. Is there a command for a new line (carriage return), or do I have to specify the cursor position for the begining of the next line?
Hi,

Sorry I missed your post. With this LCD there isn't an auto CR/LF so you will have to manually move the cursor to the next line when needed.
www.FunGizmos.com
willp
Site Admin
 
Posts: 19
Joined: February 4th, 2008, 1:21 am
Location: Woodland, WA

Re: Serial LCD Sample code

Postby gumby » December 15th, 2008, 9:24 pm

I am attempting serial communications from duemilanove. The spec sheet from the web site states that R1 and R2 should both have the jumper removed. It appears to me that R1 by default does not have a jumper. I can not find R2 on the board at all. What other jumpers is it near? Does it ship with a jumper placed on R2?
gumby
 
Posts: 1
Joined: December 15th, 2008, 9:20 pm

Re: Serial LCD Sample code

Postby hank » January 7th, 2009, 2:25 pm

Just got my Lcd in the mail and got it working. Never used this stuff before. I tried to get it to display the count but I can not get the numeric data to appear. I would appreciate knowing how to do this please.

thanks

hank
hank
 
Posts: 1
Joined: January 7th, 2009, 2:18 pm

Re: Serial LCD Sample code

Postby kallischakri » February 11th, 2009, 1:38 am

hi
im kalyan our company brought five 16*2 serial lcds from fungizmos....
for one of their prestigious project

i dont know how to display the text on the lcd could any one help me...
igone through the sample code but it consits of its own header file how to analyze the code
with out header files

could any one send me the detailed code for making this lcd to work,like how to display text on it .......
expecting reply

thanks in advance
kalyan
kallischakri
 
Posts: 1
Joined: February 11th, 2009, 1:30 am

Next

Return to Arduino

Who is online

Users browsing this forum: No registered users and 1 guest

cron