Let's Make Robots!

Problem with Serial LCD 16x2

Hi 4 all,

I use this LCD display for Arduino 328 :

http://www.emartee.com/product/41872/Arduino-Serial-LCD-1602-Shield

how can i print a variable on the lcd ?

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I have exact same programming on Arduino 2560 and Uno or Dueilanove with LCD. However 328 seems doesn't work well as shown in image. Anyone has any ideas?

 

The connection in between UNO and I2C/LCD. Only showing cubes...

 

 

 

MEGA with LCD work fine!

 

This looks like a new and different topic - I2C instead of serial LCD and a difference between MEGA and Demlthingy. The main difference I know of is pin assignments are different for I2C. Are you using A4 and A5 (not digital pins 4 & 5) on the 328 board?

Shall I open a new one? Thanks for reply~

Ok, I have a I/O shield(both on 2560 and 328), they all have I2C pin (5V,Gnd,SCL,SDA). Thought they should work the same way but only MEGA works. However, I did try A4,A5 or switch around and connect direct on board but none of them works.

I use this shield for 2560:http://www.dfrobot.com/index.php?route=product/product&path=35_39&product_id=339

this for 328:http://www.dfrobot.com/index.php?route=product/product&path=35_39&product_id=264

question and suggestion...

Have you swapped LCDs on the MEGA to make sure they both work?

Assuming you verify the LCD is fine, I would suggest you make it work without the shield first. You can find plenty of code and wiring examples for that at arduino.cc. The if adding in the shield causes the problem, DFRobot support would be able to help you. But until you have verified that the LCD and code to drive it work, it ia hard to pinpoint.

In general, yes, you should create new threads. Now that email is working again, the OP is getting all of this and possibly getting confused.

try this:

 

  int con; 
  con = 12 ;
  
  Serial.print("$PRINT ");

  Serial.println( con);

 

YES YES YES !!!!!!!!!! Works great ! Many thanx !

 

When you use Serial.print, it sends a string (unless you do special formats like print(iByte, BYTE)) of one or more characters to the device on the other end with no termination. There is nothing magical about sending everything at once. At the other end it just receives bytes until it finds the crlf termination and then tries to interpret it. it has no idea whether you sent them all at once or one byte ata time and wouldn't care if it did. When you use println, it adds the crlf termination on the end. So you don't have to put together strings with everything of the command in it. Just send it a little at a time and let the library format it for you. Use println for the last chunk so it will add the crlf for you. Arduinos don't have much RAM and literal strings are always there even if they are only used local inside a function.

 Serial.print(value, DEC);

 Maybe you should download this?

http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

 

not work,

problem is folow: You can see that all serial port order to control LCD begin with ”$”and end by ”rn” when compared with this code,Both of them is corresponding order and parameters,different commands with different parameters.

1、"GO" is  cursor movement.
2、"PRINT" is to display the serial characters on the cursor position.
3、"CLEAR" is to clear screen .
4、"HOME"is to move the cursor to the initial position of the top left corner of the screen.
5、"CURSOR" is to set the effect of  cursor, the first parameter is whether display cursor (1 and 0), the second parameter is whether blink cursor (1 and 0). 

Serial.Print() - Without "$PRINT" not displayed on this display .

void loop()
{

  int con;
  con = 12 ;
 
  Serial.print("$PRINT con r\n");

}

Output is : con

 

void loop()
{

  int con;
  con = 12 ;
 
  Serial.print(con, DEC);

}

 

Output: nothing ....

you have:

-------------------------------------------

{

  int con;
  con = 12 ;
 
  Serial.print("$PRINT con r\n");

}

------------------------------------------------

Im guesing whats between the " ... "   is what gets sent to the device.   and you have the con inside the "quotes"   if that is meant to be pin 12, try putting the 12 there, instead of con".   or build your command string differently - whats inside the (.....).