Go Down

Topic: Devantech LD03/05 LCD with Arduino Diecimila (Read 691 times) previous topic - next topic

duki

Hey everyone,

I'm trying to get the SoftwareSerial class to work with my LCD.  I can get the display to work decent, but it's not very stable. All I have hooked up is grnd, 5v, and Rx (i.e., Tx is disconnected because I don't see a use for it atm). Below is my code:
Code: [Select]


#include <Servo.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

Servo myservo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 90;    // variable to store the servo position

SoftwareSerial LCD(NOT_A_PIN, 4);  //LCD display


void setup()
{
  myservo.attach(A1);  // attaches the servo on pin 9 to the servo object
  LCD.begin(9600);
   
}


void loop()
{
  LCD.write(12);
  LCD.write(13);
  LCD.write(9);
  LCD.write(9);
  LCD.print("Progress!");
  LCD.end();

  delay(2000);
}


So basically, this clears the screen, sets the cursor to about center on the 2nd line (cr, tab, tab), and prints Progress!. This works decently, but it seems like every 5 or so loops through this, the backlight flashes and the startup screen displays before going back to "Progress!" with no backlight. Any ideas why?

floresta

What is the significance of your magic numbers?

Why do you have the code in a loop if none of the information is changing?


Don

duki


What is the significance of your magic numbers?

Why do you have the code in a loop if none of the information is changing?


Don


Sorry, I'm using this datasheet:  http://www.robotshop.com/content/PDF/datasheet-lcd05-20-4-green.pdf
If I don't have the code in a loop, it just displays my data and then returns to the default bootup screen.

floresta

#3
Aug 04, 2013, 02:51 am Last Edit: Aug 04, 2013, 03:02 am by floresta Reason: 1
Q. What is the significance of your magic numbers?
A. Sorry, I'm using this datasheet: ...

I don't see how this answers the question.  How will we know whether you picked the correct magic number for a particular step when we don't know what you are trying to do at that point.  That is the purpose of adding comments to your code.

Quote
If I don't have the code in a loop, it just displays my data and then returns to the default bootup screen.

You can't effectively troubleshoot this problem with your LCD code in loop().  Put those lines in setup() and look for what is causing your basic problem.  First of all you should remove all of the stuff relating to the servo and see if the LCD works by itself.

Don

Go Up