Go Down

Topic: Parallax LCD_2X16 example sketch (Read 2889 times) previous topic - next topic

Apr 27, 2012, 06:50 am Last Edit: Apr 27, 2012, 11:50 pm by Nick Gammon Reason: 1
Hey I am kind of new to arduino and was trying to get my parallax 27977 lcd display to work with the example sketch

Here:


Code: [Select]

/*
NOTE: you must: #include <NewSoftSerial.h>
BEFORE including the ParallaxLCD.h header
*/

#include <NewSoftSerial.h>
#include <ParallaxLCD.h>

ParallaxLCD lcd(2,2,16); // desired pin, rows, cols

void setup () {

 lcd.setup();
 delay(1000);
 lcd.backLightOn();
 lcd.at(1,4,"Milliseconds\0");
 delay(1000);
 lcd.off();
 delay(1000);
 lcd.on();
 lcd.pos(0,1);
 lcd.at(2,7,"m:\0");
 for (int b=0; b<101; b+=5) {
   lcd.pos(0,3);
   lcd.at(2,9,millis());
   delay(500);
 }
 lcd.empty();
 lcd.print("Line Feed\0");
 for (int b=0; b<51; b+=5) {
   lcd.lf();
   delay(500);
 }
 lcd.empty();
 lcd.print("Chr Return\0");
 delay(1000);
 for (int b=0; b<51; b+=5) {
   lcd.pos(0,11);
   delay(500);
   lcd.cr();
   delay(500);
 }

 lcd.cursorBlock();
 lcd.empty();
 lcd.print("Block Cursor\0");
 for (int x=1; x<16; x++) {
   lcd.pos(1,x);
   delay(500);
 }
 lcd.empty();
 lcd.pos(1,1);
 lcd.cursorUnderline();
 for (int x=1; x<16; x++) {

   lcd.pos(1,x);
   delay(500);
 }
 lcd.backLightOff();
 lcd.cursorOff();
}

void loop () {
 lcd.at(2,9,millis());
}



But when i verify the sketch I get this:

In file included from LCD_2x16.cpp:11:
C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h:23:22: error: WProgram.h: No such file or directory
In file included from LCD_2x16.cpp:11:
C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h:44: error: expected class-name before '{' token
C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h:51: error: 'boolean' has not been declared
LCD_2x16.cpp: In function 'void setup()':
LCD_2x16.pde:-1: error: 'class ParallaxLCD' has no member named 'print'
LCD_2x16.pde:-1: error: 'class ParallaxLCD' has no member named 'print'
LCD_2x16.pde:-1: error: 'class ParallaxLCD' has no member named 'print'

Any and all help is greatly apreciated.

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)

Nick Gammon


But when i verify the sketch I get this:

Code: [Select]
In file included from LCD_2x16.cpp:11:
C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h:23:22: error: WProgram.h: No such file or directory



Read this before posting a programming question

See point 2.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

there was no #include "WProgram.h" in the code so I didn't worry about it. I did add #include "Arduino.h" and i still get alot of errors

Nick Gammon

You need to edit this file:

Code: [Select]
C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h

At line 23 will be the include in question. Change that.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Line 23 is   for (int b=0; b<101; b+=5) {

Nick Gammon

Oh? Can you please post the first 30 lines of:


C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


Hey I am kind of new to arduino and was trying to get my parallax 27977 lcd display to work with the example sketch
...


It might save a considerable amount of time if you posted a link to this particular device, and a link to the exact library you are using. To save a lot of guessing.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Sorry it didn't occur to me that it would be a problem with the library classes and here's the link http://www.cyberblob.net/parallaxlcd.zip
I fixed the Arduino.h problem and now I am getting this error





In file included from LCD_2x16.cpp:11:
C:\Users\Mitchell Haley\Documents\Desk\gta and ard\ard\arduino-1.0\libraries\parallaxlcd/ParallaxLCD.h:44: error: expected class-name before '{' token
LCD_2x16.cpp: In function 'void setup()':
LCD_2x16.pde:-1: error: 'class ParallaxLCD' has no member named 'print'
LCD_2x16.pde:-1: error: 'class ParallaxLCD' has no member named 'print'
LCD_2x16.pde:-1: error: 'class ParallaxLCD' has no member named 'print'

Nick Gammon

OK, well it looks like it uses NewSoftSerial which is deprecated in version 1.0 of the IDE. I had to make a few changes to the library (attached) and a minor one to the sketch below:

Code: [Select]
/*
NOTE: you must: #include <SoftwareSerial.h>
BEFORE including the ParallaxLCD.h header
*/

#include <SoftwareSerial.h>
#include <ParallaxLCD.h>

ParallaxLCD lcd(2,2,16); // desired pin, rows, cols

void setup () {

  lcd.setup();
  delay(1000);
  lcd.backLightOn();
  lcd.at(1,4,"Milliseconds\0");
  delay(1000);
  lcd.off();
  delay(1000);
  lcd.on();
  lcd.pos(0,1);
  lcd.at(2,7,"m:\0");
  for (int b=0; b<101; b+=5) {
    lcd.pos(0,3);
    lcd.at(2,9,millis());
    delay(500);
  }
  lcd.empty();
  lcd.print("Line Feed\0");
  for (int b=0; b<51; b+=5) {
    lcd.lf();
    delay(500);
  }
  lcd.empty();
  lcd.print("Chr Return\0");
  delay(1000);
  for (int b=0; b<51; b+=5) {
    lcd.pos(0,11);
    delay(500);
    lcd.cr();
    delay(500);
  }

  lcd.cursorBlock();
  lcd.empty();
  lcd.print("Block Cursor\0");
  for (int x=1; x<16; x++) {
    lcd.pos(1,x);
    delay(500);
  }
  lcd.empty();
  lcd.pos(1,1);
  lcd.cursorUnderline();
  for (int x=1; x<16; x++) {

    lcd.pos(1,x);
    delay(500);
  }
  lcd.backLightOff();
  lcd.cursorOff();
}

void loop () {
  lcd.at(2,9,millis());
}


Now it compiles OK.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Thank you so much it worked perfectly

WinstonP

#10
Aug 18, 2012, 10:46 pm Last Edit: Aug 19, 2012, 02:49 am by WinstonP Reason: 1
At least one person was helped. Maybe you could help me also.
I've downloaded the .cpp and the .h files and the sketch file and compiled with no errors but all I get on the display is "\" and the cursor advances one space; but only when I reset the arduino. No backlight or anything.
The self test via the switches does work and I have tried all three baud rates.

Any additional help will be greatly appreciated.

(and I'll wait until you Aussies wake up)

Winston
=============
checking on another thread, I noticed that my TX/RX LEDs weren't flashing when I uploaded a program. COM port had been changed. one problem down, more to go.
Now I get the cursor moving about plus a few tones and after 30 seconds or so, it sounds like it's trying to play some tune. From the looks of the sketch; I don't think it's supposed to be playing any tunes.

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

WinstonP

There's only 3 wires (5v, Gnd and data). Could the length of the wires be a problem. They're not shielded, only twisted, and 19" long (48cm) long. {I don't remember if ya'll use metric or not). I'll try a different jumper cable. one shorter and one shielded and try again.

Winston

WinstonP

Nevermind. I tried this code:

Code: [Select]

const int TxPin = 6;

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

void setup() {
   
  pinMode(TxPin, OUTPUT);
  digitalWrite(TxPin, HIGH);
 
  mySerial.begin(9600);
  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 Parallax!");   // Second line
  mySerial.write(212);                // Quarter note
  mySerial.write(220);                // A tone
  delay(3000);                        // Wait 3 seconds
  mySerial.write(18);                 // Turn backlight off
}
void loop() {
}


from http://learn.parallax.com/KickStart/27977 and it works. My guess is a problem with the Parallax .h or .cpp code that's causing a problem.

Thanx anyways....

Winston

Go Up