Pages: [1]   Go Down
Author Topic: Problem with Parallax serial LCD  (Read 1092 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been trying to program custom characters on a Parallax serial LCD with the Arduino. I have the LCD working, but it does not fully work with the custom characters. You setup custom characters by sending the display 8 bytes of display data that corresponds to the pixels on each 5x8 pixel character area. only the first 5 bits of each byte is kept, so you do not actually need the last three bits. Please see my code for a better explanation. The problem is that when I try to make a 5x8 character area solid black by filling the 8 bytes entirely with 1's, the display only shows three columns of pixels on the right side of the character area. I need to fix this or I cannot make custom characters. The display does this at random times, and not only when I send all 1's.

Here are pictures of the problem:  http://xlabs.eng.usf.edu/index.php/forum/13-microcontrollers-/30-problem-with-parallax-lcd

Here is my code:
Code:
//Parallax 2x16 Serial LCD

#include <NewSoftSerial.h>  

NewSoftSerial mySerial (2, 3); //LCD RX is connected to pin 2

void setup() {
 mySerial.begin(9600);
 pinMode(1, OUTPUT);
 delay(10);
 mySerial.print(17, BYTE);   //Turns Backlight ON
 delay(10);
}

void loop() {
 mySerial.print(12, BYTE);  //Clears Display
 delay(10);
 mySerial.print("Hello CoytHV");   //Hello CoytHV
 mySerial.print(142, BYTE);  //Move cursor to line 0, position 14
 Character1();  //Display Custom Character
 delay(5000);
}

void Character1() {  //This custom character works
 delay(10);
 mySerial.print(252, BYTE);  //Define Custom Character 4
 mySerial.print(11101, BYTE);  //8 byte display data follows
 mySerial.print(11101, BYTE);
 mySerial.print(11101, BYTE);
 mySerial.print(11101, BYTE);
 mySerial.print(11101, BYTE);
 mySerial.print(11101, BYTE);
 mySerial.print(11101, BYTE);
 mySerial.print(11101, BYTE);
 mySerial.print(4, BYTE);  //Display custom character 4
 
}

//THis custom character does not work, and defaults to 3 coulmns of pixels on the right.
// mySerial.print(11111, BYTE);  //8 byte display data follows
// mySerial.print(11111, BYTE);
// mySerial.print(11111, BYTE);
// mySerial.print(11111, BYTE);
// mySerial.print(11111, BYTE);
// mySerial.print(11111, BYTE);
// mySerial.print(11111, BYTE);
// mySerial.print(11111, BYTE);

Any ideas?
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 7
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Any ideas?

All of the numbers in your program are decimal.

When you send decimal 11111 to a byte-printing function, it looks at the eight least significant bits (binary).

The sixteen-bit decimal number 11111 is equal to binary 0010101101100111 and the five least significant bits are "00111", which is what you are seeing as the character is displayed.

If you want a bit pattern consisting of five ones in the least significant bits you can use one of the binary constants #defined in Arduino's binary.h to make it easy to see what the heck it is:

Code:
mySerial.print(B00011111, BYTE);

Now it "just happens" that the sixtteen-bit decimal number 11101 is equal to binary 0010101101011101, so the five least significant bits are "11101"  Maybe you just got lucky.  (Or maybe it is actually unlucky, since it gave you the false sense of correctness arising from seeing from what you wanted to see).

Anyhow---a better (less obfuscatory) way of specifying a byte whose five least significant bits are "11101" is  with
Code:
mySerial.print(B00011101, BYTE);



Regards,

Dave
« Last Edit: July 07, 2010, 12:34:32 am by davekw7x » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Dave! That is exactly what I needed. The LCD is now working properly.

I am new to Arduino, so I was trying to take Basic Stamp code for the LCD and converting it to Arduino code. I am starting to realize some of the differences between the two such as problems like this.

Thanks for the help!
Logged

Pages: [1]   Go Up
Jump to: