Just got my Seeeduino Mega, problems with LCD

Hi

I got my Seeeduino Mega today, and have tried different things, but now i wanted to interface the LCD i bought also, but i have some problems. When i try to print text on the LCD, some of the pixels on the screen just flashes, or the buttom half is all black

I have tried both the regular LiquidCrystal library and the one from Seeed Studio, who have made the screen.

The screen: http://www.seeedstudio.com/depot/lcd-162-characters-green-yellow-back-light-p-62.html?zenid=c4464509f1c929068e8719c2022bb798

My wiring: http://peecee.dk/uploads/112009/IMAGE_015.jpg

The Error: http://peecee.dk/uploads/112009/IMAGE_014.jpg

Anyone of you who have gotten this error before?

Best Regards Zeecue

Zeecue;

Anyone of you who have gotten this error before?

Hundreds, maybe thousands have.

... or the buttom half is all black ...

It's upside down - it's the top line that is black, because your LCD controller is not initialized properly.

I have tried both the regular LiquidCrystal library and the one from Seeed Studio ...

The 'updated' library from Seeedstudio was horribly out of date the last time I checked (a few days ago). Use the LiquidCrystal library from v0017 of Arduino. Make sure you undo all of the stuff that Seeedstudio had you do with the library.

Your wiring photo is not too clear but it looks like you have no connections to any of the control or data lines on the LCD module except for D7 which you have tied to +5v. Go to the Arduino site at http://arduino.cc/en/Tutorial/LiquidCrystal and follow the wiring diagram there. You can probably leave the contrast pin (pin 3) grounded since that is what Seeedstudio recommends, but the pot would be better. Do NOT use the example program there (until they fix it) but instead use the sample 'Hello World' program supplied with the library.

Don

Hi

Ohh, forgot to mention, that i have pins on most of the lines, exept the 5v and ground, so i can plug it directly in to the arduino. I use the v0017 Arduino software, i have a seperate folder for the Seeeduino library.

Heres a drawing of how i connected the wires to the LCD, so i can use it directly on the Arduino. http://peecee.dk/uploads/112009/lcd_big_thumb.jpg

And thank you, really quick and good answer. ;)

Best Regards

I have tried to wire the LCD up like in the LiquidCrystal guide, and with that wiring the LCD dont even turn on.

Update: I also tried this, from the Seeedstudio site:

Hook everything up EXACTLY like in this picture from the Arduino page: http://arduino.cc/en/uploads/Tutorial/lcd_schem.png Now load the "Scroll" Example from Arduinos LiquidCrystal Library. Change these two lines

lcd.begin(16, 2); lcd.setCursor(0,7);

to

lcd.begin(8, 2); lcd.setCursor(0,0);

now upload it to your Arduino or Seeduino and watch your display fire up! You may have to adjust the potentiometer a little if you can't see anything.

As an alternative to the potentiometer you can connect the Vo pin of the LCD with any available PWM-output (I use pin 9) and add the following code in the setup() section:

pinMode(9, OUTPUT); analogWrite(9, CONTRAST);

replace CONTRAST with the value of your choice. Values around 10-20 give a nice bright output.

But the LCD only have black squares on the top half. Hmm, should i just buy another LCD, thats easier to interface with?

The black squares on the top line indicate that your LCD is functioning, it just hasn't been initialized properly. Buying another LCD won't help, just about all of the character LCDs use the same interface. If you can't get that to work you will never get a graphical LCD to work.

Your next step should be to post a photograph that clearly shows the actual connections to your LCD module, not a drawing of what you think you are connecting. You should also post the code that you are actually using, not a link to what you think you are using.

Don

Hi again.
Here is a picture of the connections(it was the best picture i could get, i own a really old digital camera)
http://peecee.dk/uploads/112009/IM000749.JPG

/*
  LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD and uses the
 scrollDisplayLeft() and scrollDisplayRight() methods to scroll
 the text.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe 
 modified 25 July 2009
 by David A. Mellis
 
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(8, 2);
  //lcd.setCursor(0,0);  // Have tried with this uncommented also, same error
  // Print a message to the LCD.
  lcd.print("hello, world!");
  delay(1000);
  // Sets the Contrast on the LCD, 10-20 is OK, on pin 9
  pinMode(9, OUTPUT);
 analogWrite(9, 10);
}

void loop() {
  // scroll 13 positions (string length) to the left 
  // to move it offscreen left:
  for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft(); 
    // wait a bit:
    delay(150);
  }

  // scroll 29 positions (string length + display length) to the right
  // to move it offscreen right:
  for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
    // scroll one position right:
    lcd.scrollDisplayRight(); 
    // wait a bit:
    delay(150);
  }
  
    // scroll 16 positions (display length + string length) to the left
    // to move it back to center:
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft(); 
    // wait a bit:
    delay(150);
  }
  
  // delay at the end of the full loop:
  delay(1000);

}

You need to Ground pin 5 on the LCD (R/W pin), just put a jumper from that pin to ground and you should be good to go.

Also, I don't think controlling contrast from a PWM pin is the best way to go... I highly suggest using a trimmer pot, or any other kind of potentiometer you have. (others may suggest differently but this is just personal preference)

Also it's really hard to tell.. so I'm probably wrong, but it looks like the wire going to pin 2 or 1 on the Mega is.. well in pin 1, when it should be in pin 2. Lol you've probably got it right just checking. :)

Well I thought I clearly asked for a clear picture - maybe it's my monitor or my eyes. CaptainObvious spotted the obvious problem (R/W not grounded) in spite of the out of focus picture. You may have gotten tripped up by this statement in the Arduino tutorial "The R/W pin is not connected, ..." which is clearly wrong (although the diagram shows it grounded).

I agree that you should not try control the backlight via PWM while you are also trying to get the LCD to work. You really shouldn't mess with PWM until you are sure that you know how to display characters on the LCD.

You have also selected an example program that uses some advanced techniques. You should start with a simpler example, such as 'Hello World' - but be sure to follow the recommendations in my earlier post.

Don

Hi again

And thank you all for the really good answers, it got it to work now, it was the pin 5 on the LCD, that wasnt connected to ground, a newbie mistake i guess.
I started with the scrolling example because it was the one seeedstudio wrote to try with.

Update heres my working code, for displaying temperature and uptime on LCD.

// include the library code:
#include <LiquidCrystal.h>
#include <avr/pgmspace.h>

int led_state;
unsigned long time;

#define THERM_PIN   7  // 10ktherm & 10k resistor as divider.

// Big lookup Table (approx 750 entries), subtract 238 from ADC reading to start at 0*C. Entries in 10ths of degree i.e. 242 = 24.2*C Covers 0*C to 150*C For 10k resistor/10k thermistor voltage divider w/ therm on the + side.
const int temps[] PROGMEM = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 143, 144, 145, 146, 147, 148, 149, 150, 151, 151, 152, 153, 154, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 164, 165, 166, 167, 167, 168, 169, 170, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 180, 181, 182, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 197, 198, 199, 200, 201, 202, 203, 204, 205, 205, 206, 207, 208, 209, 210, 211, 212, 212, 213, 214, 215, 216, 217, 218, 219, 220, 220, 221, 222, 223, 224, 225, 226, 227, 228, 228, 229, 230, 231, 232, 233, 234, 235, 235, 236, 237, 238, 239, 240, 241, 242, 243, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255, 256, 257, 258, 259, 260, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 422, 423, 424, 425, 426, 427, 428, 429, 430, 432, 433, 434, 435, 436, 437, 438, 439, 441, 442, 443, 444, 445, 446, 448, 449, 450, 451, 452, 453, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 468, 469, 470, 471, 472, 474, 475, 476, 477, 479, 480, 481, 482, 484, 485, 486, 487, 489, 490, 491, 492, 494, 495, 496, 498, 499, 500, 501, 503, 504, 505, 507, 508, 509, 511, 512, 513, 515, 516, 517, 519, 520, 521, 523, 524, 525, 527, 528, 530, 531, 532, 534, 535, 537, 538, 539, 541, 542, 544, 545, 547, 548, 550, 551, 552, 554, 555, 557, 558, 560, 561, 563, 564, 566, 567, 569, 570, 572, 574, 575, 577, 578, 580, 581, 583, 585, 586, 588, 589, 591, 593, 594, 596, 598, 599, 601, 603, 604, 606, 608, 609, 611, 613, 614, 616, 618, 620, 621, 623, 625, 627, 628, 630, 632, 634, 636, 638, 639, 641, 643, 645, 647, 649, 651, 653, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 683, 685, 687, 689, 691, 693, 695, 697, 700, 702, 704, 706, 708, 711, 713, 715, 718, 720, 722, 725, 727, 729, 732, 734, 737, 739, 741, 744, 746, 749, 752, 754, 757, 759, 762, 764, 767, 770, 773, 775, 778, 781, 784, 786, 789, 792, 795, 798, 801, 804, 807, 810, 813, 816, 819, 822, 825, 829, 832, 835, 838, 842, 845, 848, 852, 855, 859, 862, 866, 869, 873, 877, 881, 884, 888, 892, 896, 900, 904, 908, 912, 916, 920, 925, 929, 933, 938, 942, 947, 952, 956, 961, 966, 971, 976, 981, 986, 991, 997, 1002, 1007, 1013, 1019, 1024, 1030, 1036, 1042, 1049, 1055, 1061, 1068, 1075, 1082, 1088, 1096, 1103, 1110, 1118, 1126, 1134, 1142, 1150, 1159, 1168, 1177, 1186, 1196, 1206, 1216, 1226, 1237, 1248, 1260, 1272, 1284, 1297, 1310, 1324, 1338, 1353, 1369, 1385, 1402, 1420, 1439, 1459, 1480, 1502 };


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(8, 2);
  // Sets the Contrast on the LCD, 5-10-20 is OK, on pin 9
  pinMode(9, OUTPUT);
  analogWrite(9, 5);
  // Print a message to the LCD.
  lcd.print("Temperatur:");
  // Print seconds to second line:
  lcd.setCursor(0,1);
  lcd.print("Uptime:");
}

void loop() {
  int therm;   
  therm=analogRead(THERM_PIN)-238;
  therm=pgm_read_word(&temps[therm]);
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(12, 0);
  // print the converted value to LCD
  lcd.print(therm/10);
  delay(500); // Waits for 500ms
  lcd.setCursor(8, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

Best Regards