Go Down

Topic: Scroll Text LCD Row 1 , no scroll text at Row 2 (Read 3295 times) previous topic - next topic

ArduinoPat

Nov 17, 2012, 06:41 pm Last Edit: Nov 17, 2012, 06:43 pm by ArduinoPat Reason: 1
Dear All,

Here my setup ; Arduino Uno , LCD  connected with the PCF8574A ( I2C )  



I have experiment with the follow sketch:
Code: [Select]
/*
 Scroll
 * this sketch scrolls text left when tilted
 * text scrolls right when not tilted.
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

const int numRows = 2;
const int numCols = 16;

const char textString[] = "                  * ArduinoPat *      ";
const int textLen = sizeof(textString) -1;
boolean isTilted = false;
LiquidCrystal_I2C lcd(0x38,16,2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.begin(numCols, numRows);
  lcd.print(textString);
}

void loop()
{
 {
  for (int position = 0; position  < textLen; position++)
   {
     lcd.scrollDisplayLeft();
     delay(150);
   }
 }
 {
   for (int position = 0; position  < textLen; position++)
   {
     lcd.scrollDisplayRight();
     delay(150);
   }
 }
}
     
   



In Row one the text scrolls ( that's what i want )
But i will also put text at Row two, but whatever i try , this text will scroll either.

Maby some of you can give me a correct answer , the text will stay at Row two.

Many thanks for reading this topic


Regards ,

ArduinoPat
Patrick ,The Netherlands

PaulS

Quote
But i will also put text at Row two, but whatever i try , this text will scroll either.

That's what the scrollDisplayLeft() and scrollDisplayRight() methods do.

You want to emulate scrolling, by changing the message shown on line 1 each time through loop.

Show like so
Code: [Select]
Arduino is great
rduino is great A
duino is great Ar


It isn't that difficult to shift the array around. Even better, though, is to simply print two different parts of the one array each time. First, print 0 to n of the array and nothing. Then, print 1 to n and 0. Then 2 to n and 0 to 1. Then, 3 to n and 0 to 2. Keep this up until you are printing n and 0 to n-1. Next time, you start over.

Get rid of the unnecessary curly braces in loop.

ArduinoPat

Dear PaulS

Thanks for reply,

I want a text show at row 2 but without scroll effect,

Row 1 is scrolling text now , and that is what worked well now,

Maby you can show me an option to bring this at my sketch

Thanks,

ArduinoPat
Patrick ,The Netherlands

job_revi

#3
Jan 30, 2013, 08:07 am Last Edit: Jan 30, 2013, 08:09 am by job_revi Reason: 1
Code: [Select]

#include<LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

String txtsc,txtnosc;
void setup(){
  txtnosc="Text No Scroll";
  txtsc="Text Scrolling  "
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(txtnosc);
}

void loop(){

          lcd.setCursor(0,1);
           txtsc=ScrollTxt(txtsc);
           lcd.print(txtsc);
}

String ScrollTxt(String txt){
 return txt.substring(1,txt.length()) + txt.substring(0,1);
}


i hove this help  :smiley-mr-green:

"Semoga membantu"
Berbagi itu indah

Chamayo

#4
Jun 08, 2015, 01:47 am Last Edit: Jun 08, 2015, 01:49 am by Chamayo Reason: Remove ino
That worked great but then my ATTiny85 ran out space as fast as you can count bits. I want to post my results in case someone needs a little nudge in the future.

I stayed up all night tweaking out this code that works great with the ATTiny85:

Code: [Select]
byte counter = 1, ceiling = 18,  leadingPos = 0;

void animation(byte textChoice){ //method accepting a number for distinct choice of text for message
 char * message; //33 characters sized for 20x4 LCD
 if(textChoice == 0){
     message = "Good Morning                    "; //33 chars exactly
 }
 else if(textChoice == 1){
     message = "Good Afternoon                  "; //33 chars exactly
 }
 else if(textChoice == 2){
     message = "Good Evening                    "; //33 chars exactly
 }
 else if(textChoice == 3){
     message = "Good Night                      "; //33 chars exactly
 }

   lcd.setCursor(ceiling,0); //ceiling initialized to 19 outside of method's scope
   for(byte n = leadingPos; n <= counter; n++){ //counter initialized to 0 outside of method's scope
     lcd.print(message[n]);
   }

 ceiling -= 1;
 counter += 1;
 if(counter >= 19){ //after 20th iteration for 20 pixel widths, increase leadingPos to snip leading characters
  leadingPos += 1;
 }
 if (counter == 32){ //number equal to message length or greater outputs artifacts, while less results in incompleteness
  counter = 0 ; //reset counter to 0 after one successful scroll
  ceiling = 19; //reset ceiling to 19 after one successful scroll
  leadingPos = 0; //reset leadingPos to 0 after one successful scroll
 }
 


}





HazardsMind

I made a solution for this very same problem about a year ago, its somewhere on the forum though. If I had my laptop I would give you a working sketch but sadly I am on my tablet and won't be back home until tomorrow night. If you want, look up LCD compass and my username, you should be able to find the post.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Go Up