Pages: [1]   Go Down
Author Topic: Help with Parallax 2x16 Serial LCD?  (Read 1756 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to get this LCD working, but it seems nothing I do works.
I started searching around, and I found a link, but it's dead. Link: www.cyberblob.net/parallaxlcd.zip
My code isn't working either. Here is my code:
Code:
void setup() {
  Serial.begin(9600);
}

void loop() {
  lcd_turnOn();
  lcd_backlightOn();
}

void lcd_clear() {
  Serial.write(12);
  delay(5);
}

void lcd_newLine() {
  Serial.write(13);
}

void lcd_turnOn() {
  Serial.write(22);
}

void lcd_backlightOn() {
  Serial.write(17);
}

void lcd_backlightOff() {
  Serial.write(18);
}
And on the back of the LCD device, I have switch 1 set to off, and switch 2 set to on, which is what they ask me to do in the documentation.
I've also tried changing all "Serial.write" to "Serial.print" and "Serial.println" and nothing happened still.

So does anyone know what I can do to get this thing working? The examples shown on the documents provided by Parallax are not for Arduino, and are in BASIC. Docs: http://www.parallax.com/dl/docs/prod/audiovis/SICSerialLcd.pdf

Any help would be highly appreciated!
« Last Edit: April 29, 2012, 05:36:29 pm by _Marcus » Logged

Offline Offline
Edison Member
*
Karma: 64
Posts: 2450
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think that you have to send it some text to display.
And make sure the DIPswitches are right for 9600.
(If you don't have the backlight version then that won't work.)
Code:
void setup()
{
  Serial.begin(9600);
  Serial.write(22);
  Serial.write(12);
  delay(5);
  Serial.print("Hi Guy");
}

void loop()
{
  lcd_turnOff();
  delay(500);
  lcd_turnOn();
  delay(500);
}

void lcd_turnOn()
{
  Serial.write(22);
}

void lcd_turnOff()
{
  Serial.write(21);
}

* * * *  There's a "Kickstart" with Arduino example --
https://sites.google.com/site/parallaxinretailstores/home/2x16-serial-lcd-backlit
It uses 'software serial' though.

When using Arduino TX (D1/pin1) you should probably disconnect the USB first?  Not sure.
Disconnect the LCD from TX when programming.  Disconnect USB.  Connect LCD.  Power up.  ?
« Last Edit: April 29, 2012, 05:51:09 pm by Runaway Pancake » Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4250
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The LCD does not need to be 'refreshed'.  Any information that you send to it will remain there until it is overwritten.

You generally only send information to the display in loop() if that information is changing, such as periodically updating a clock.

If you want to see if you can successfully display anything on the display you will have to do this in setup().   You should go back and try sending some information to the display in setup() and get that part working before you try to do anything with loop().


Don

[Edit]:  Did you look at the Arduino 'kickstart' example that was referred to in Reply #1?  Did you notice that loop() has nothing in it?
« Last Edit: April 29, 2012, 07:25:41 pm by floresta » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wrote this code this morning and it worked first time before I started playing with it but it may help.




const int TxPin = 7;
const int Baud = 9600;

#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);


int loopCount = 0;

void setup() {
   
  pinMode(TxPin, OUTPUT);
  digitalWrite(TxPin, HIGH);
 
  mySerial.begin(Baud);
  delay(100);
  mySerial.write(12);                 // Clear             
  mySerial.write(17);                 // Turn backlight on
  delay(5);                           // Required delay
  mySerial.print("Hello, world...");  // First line
  mySerial.write(13);                 // Form feed
  mySerial.print("from Ernie!");   // Second line
  mySerial.write(212);                // Quarter note
  mySerial.write(220);                // A tone

}

void loop() {
 
  delay (1000);
  mySerial.write(21);
  delay (1000);
  mySerial.write(22);
  delay (1000);
  mySerial.write(18);
  delay (1000);
  mySerial.write(17);
  delay (1000);
  mySerial.write(12);
  delay(5);
  mySerial.print("   Loop Count ");
  mySerial.write (155);
  mySerial.print(loopCount++);
 
}
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4250
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I wrote this code this morning and it worked first time before I started playing with it but it may help.

If you want to make your post a lot more useful then you could add some comments that explain the magic numbers in your loop expressions.

If you want to make your post a lot more legible you could highlight the code portion of the post and use the 'code' button (the #) to make it look like the code in reply #1


Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don, point well taken.

Here is a program which uses the serial display and a simple pot fro gnd to +5 and it works as a voltmeter.
Hope it is helpful to others.

Ernie

Code:
/*
  LiquidCrystal Serial
 
 Demonstrates the use a Paralax 2X16 Serial LCD display. 
 
 This sketch prints "Hello, world..." to the first line LCD 
 and "From Ernie" in the second line. It then loops with a
 counter running and  plays with the backlight and display.
 
 The circuit:
 * LCD Serial Pin to digital pin 7
 
 By Ernie Bose
 Created 2 May 2012
 by Ernie Bose
 
  This example code is in the public domain.
  display information can be found here:
    http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/27976-7-9-ParallaxSerialLCD-v3.0.pdf
    The command set describes what each command does to the display.
 */


//============================================================================
//  Constants used so all the setup stuff is in one place

//============================================================================

const int TxPin = 7;               // serial output to display
const int VinPin = A0;              // analog input for measurement
const int Baud = 9600;


#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

//============================================================================
// The int2voltstr subroutine converts an integer value in the range 0 to 1024
// and converts it to a string of the format 00.00. The value is scaled by the
// map function so that the range is scaled to represent 0 to 500 for 5 volts.
//
// The string is returned.
//============================================================================

String int2voltstr (int v)
{

  int vv = v;
  char voltageString[6];

  // Do these two first since they don't change:
  voltageString[5] = 0;    // Null termination for the string
  voltageString[2] = '.';  // Decimal separator can be changed to comma


  // Make the value be in between 0 and 500
  int mappedValue = map( vv, 0, 1023, 0, 500 );

  // Working backwards, take the bottom digit and shift
  voltageString[4] = '0' + mappedValue % 10; // Take the bottom digit
  mappedValue /= 10;    // Shift by one digit
  voltageString[3] = '0' + mappedValue % 10; // Take the bottom digit
  mappedValue /= 10;    // Shift by one digit

  // Decimal was already written above, skip voltageString[2]
  voltageString[1] = '0' + mappedValue % 10; // Take the bottom digit
  mappedValue /= 10;    // Shift by one digit
  voltageString[0] = '0' + mappedValue % 10; // Take the bottom digit

  return voltageString;
}


void setup() {
   
  pinMode(TxPin, OUTPUT);
  digitalWrite(TxPin, HIGH);
  pinMode(VinPin, INPUT);
  mySerial.begin(Baud);               // Set serial Baud rate
  delay(100);                         // wait for the display 
  mySerial.write(12);                 // Clear             
  mySerial.write(17);                 // Turn backlight on
  delay(5);                           // Required delay
  // The next lines are for debug purposes and not needed in the final
  //mySerial.print("Hello, world...");  // First line
  //mySerial.write(13);                 // Form feed
  //mySerial.print("from Ernie!");      // Second line
  //mySerial.write(212);                // Quarter note
  //mySerial.write(220);                // A tone

}

void loop() {
 
  String strVolts;                    // String to store the results

  int volts = analogRead(VinPin);    // Get the value from the input pin
  mySerial.write(12);                // write form feed to the display to clear
  mySerial.write(148);               // put the cursor at the beginning of line 2
 
  mySerial.print(volts);             // print the raw analog pin data
  strVolts = int2voltstr (volts);    // convert the raw data into a scaled string
 
  mySerial.write(128);                // put the cursor on the top line
  mySerial.print(" Volts = ");
  mySerial.print(strVolts);           // print Volts = xx.xx
  delay(200);                         // let the display catch up and do it again
 
}
Logged

Pages: [1]   Go Up
Jump to: