i want to make an message like this
first line fixed
Hello
Second line scrolling
Some text here
how to doo it?
Im using a 16x2 LCD and LiquidCrystal Library
i want to make an message like this
first line fixed
Hello
Second line scrolling
Some text here
how to doo it?
Im using a 16x2 LCD and LiquidCrystal Library
If you first try to do these, I think you will figure it out:
Use LiquidCrystal440 library first.
Not sure if that lets you just scroll the bottom line though.
If you not shure why you post it??
If you not shure why you post it??
That library may help you get something on the LCD, which is a good step towards what you want to do.
If you not shure why you post it??
Because it's a much better updated library for running HD44780 compatible LCDs.
The HD44780 cannot inherently scroll one line without the other and I don't think that LiquidCrystal440 addresses this problem either. The best (but not too good) way to accomplish this might be to scroll both lines and then rewrite the "fixed" line.
Don
This is a really stimulating question. Don (floresta) has a good suggestion and something like that is probably the way to go BUT
you need to understand 2 differences between LiquidCrystal in Arduino 17 and 18 and LiquidCrystal440 and its descendants.
17,18: Lets you write to the HD44780 RAM that is off screen. this seems desirable for you as you write the second line. However if you
lcd.scrollDisplayLeft();
lcd.setCursor(0,0);
lcd.print("abcd");
what you will see on the top line is "bcd"
440: Doesn't let you write to the HD44780 RAM that is offscreen (at least if you properly declare the size of your LCD in lcd.begin(16,2); ... hmmmm)
instead it will wrap the text onto the start of the next line or back to the top line. But if you
lcd.scrollDisplayLeft();
lcd.setCursor(0,0);
lcd.print("abcd");
what you will see on the top line is "abcd".
There are 2 separate fixes in play, one to fix the linewrap issue (17,18 wraps text on a 4 line LCD from line 0 to line 2, 440 wraps it from line 0 to line 1) and another bugginess that left setCursor in 17,18 pegged to the HD44780's RAM rather than to the screen position.
I haven't quite :-/ worked out in my head what will happen in 440 if you have a 16x2 and declare it as lcd.begin(40,2). That will let you write to the RAM that is not onscreen but what will happen to the 'setCursor after scroll' fix?? I think for small numbers it may work ok.
The idea of using lcd.begin(40,2) works!
This uses one of the latest descendants of LiquidCrystal440 and uses Don's idea to do what I think you want. the pins and setup are for a Mega; it works on a 16x2 and would be strange on a 4 line display.
#include <LiquidCrystal.h>
uint8_t nRows = 2; //number of rows on LCD
uint8_t nColumns =40; //number of columns
uint8_t rw = 255; //255 if rw is connected vs 47 (or 49 for the 24x2) in the examples below; it should be pulled to GND if not controlled by the interface.
LiquidCrystal lcd(49,47,45, 35,33,31,29);
byte BACKLIGHT, BACKLTGND, POWER5V, GNDMain;
void setup(void) {
// set some digital pins to high and low to provide LCD with power and gnd:
// most of them: 2x16,4x20 4x16
BACKLIGHT = 27; // pin 27 will control the backlight //before I solder pins in, I check current on the backlight
BACKLTGND = 25; // PIN 25 will be set LOW to provide a Gnd for the backlight
POWER5V = 53; // we will set this HIGH to provide power on pin 2 of the LCD
GNDMain = 255; // next to pin 53 (in the pin "55" position) is a GND--pin 1 of the LCD goes there
pinMode(POWER5V, OUTPUT); //We're using a digital out as a 5V power source for the LCD
digitalWrite(POWER5V, HIGH);
if (BACKLIGHT != 255) {
pinMode(BACKLIGHT, OUTPUT); //set 255 if you need to wire backlight to gnd bo high current draw
digitalWrite(BACKLIGHT, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
pinMode(BACKLTGND, OUTPUT); //We're using a digital out as a GND for the backlight
digitalWrite(BACKLTGND,LOW);
}
randomSeed(analogRead(0)); //read unconnected pin to seed random number generator
lcd.begin(nColumns,nRows); //this is absolutely needed with this arrangement on the Mega--power was not
// applied to the LCD when it was initialized as lcd was instantiated above!!
}
void loop(void) {
uint8_t i = 0;
uint8_t rand=random(150);
lcd.clear();
lcd.setCursor(0,0);
lcd.println("Line 1 ");
lcd.print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN");
while (i < rand) {
lcd.scrollDisplayLeft();
lcd.setCursor(0,0);
lcd.print("Line 1 ");
i++;
delay(100);
}
}
The idea of using lcd.begin(40,2) works!
I'm sure you guys know the HD44780 controller in and out, but why do you insist on doing this in "hardware"? There is nothing to prevent you from doing soft scroll by simply rewritig the line shifted one position left or right with a timed interval between positions. Or is there?
You could:
There is basically no end to what you can do with soft "scrolling" and it should all work with the standard library.
BenF is, of course, correct. It could be done that way too; that solution, I think, is a little more work on the Arduino side (but perhaps less work in the programmer's head!) but doesn't limit your scrolled message to 40 characters.
... but why do you insist on doing this in "hardware"?
None of our solutions can be done in hardware - that would require changing the code in the LCD controller. Your statement would more accurately be but why do you insist on doing this in "the library"?
Possible answers:
(1) A professional programmer likes to figure something out once, put it in a library, and then use it over and over again in many different applications.
(2) A non-technical type may like to have someone else figure it out and put it in a library where he (the not-techie) can use it without knowing all the details behind what makes it function.
I myself prefer to have each program self contained and completely documented so I tend to do things the way you have proposed.
Don
Your statement would more accurately be but why do you insist on doing this in "the library"?
Not so - my point is that you seem to be locked on using the HD44780 scroll feature and the "simple" answer to the original request gets lost on the way.
The topic question asked is plain and simple and I trust close to what many users have done before him. Visual effects on small LCD's is no magic and a good match for an Arduino application.
When it comes to libraries, I'm much more in favor of a simple "hardware abstraction" layer for micro controllers (minimum code, fast). This leaves the application builder with full power and flexibility without the negatives of someones interpretation of what might be useful. As an example, the OneWire library is an excellent addition, the DS18B20 "library" on the other hand is better written as a simple 10 line purpose built application.
This is not Windows - we need small compact building blocks - not comprehensive, ineffecient do all for everyone libraries (not to say the recent efforts of mr. jrraines however fall into the latter category).
I want code for this in embedded C
I want code for this in embedded C
For your Arduino?
the "right" way to do this is to not scroll the fixed text on the top line and keep printing the bottom line at a new position (plus a character to erase the tail)
if you move all the text then reprint the top line, the top line will flicker.
i.e. (pseudoy code)
gotoxy(0,0)
lcdprint("Hello")
for(int x = 15; x >=0; x--){
gotoxy(x,1)
lcdprint("Scrolling... ")
pause(500)
}