Pages: [1]   Go Down
Author Topic: Parallax LCD_2X16 example sketch  (Read 2534 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
  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)
« Last Edit: April 27, 2012, 04:50:42 pm by Nick Gammon » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

But when i verify the sketch I get this:

Code:
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.
Logged


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

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to edit this file:

Code:
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.
Logged


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

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


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

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'
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
  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.

* ParallaxLCD.cpp (3.68 KB - downloaded 67 times.)
* ParallaxLCD.h (3.38 KB - downloaded 57 times.)
Logged


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

Thank you so much it worked perfectly
Logged

Georgia, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 18, 2012, 07:49:47 pm by WinstonP » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 481
Posts: 18742
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like a wiring problem.
Logged


Georgia, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Georgia, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nevermind. I tried this code:

Code:
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
Logged

Pages: [1]   Go Up
Jump to: