And can someone help me with my first question? ![]()
I have the program for scrolling one line of text on LCD display and now I want to stop this move using the button. When I stop, the text moves to the starting position, but I want to stop on the position before the using button (for example on the middle of display).
This is my code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);Â Â Â Â Â
int screenWidth = 16;
int screenHeight = 2;
String line1 = "line 1";
String line2 = "line 2";
int stringStart, stringStop = 0;
int scrollCursor = screenWidth;
int lcd_key  = 0;
int adc_key_in = 0;
#define btnLEFTÂ 3
int read_LCD_buttons() {Â Â Â Â Â
  adc_key_in = analogRead(0);Â
}
Â
void setup()
{Â lcd.begin(16, 2);Â
} // start the library
void loop()
{
{Â lcd.setCursor(scrollCursor, 1);
 lcd.print(line2.substring(stringStart,stringStop));
 lcd.setCursor(0, 0);
 lcd.print(line1);
 delay(300);
 lcd.clear();
Â
 if(stringStart == 0 && scrollCursor > 0){
  scrollCursor--;
  stringStop++;
 } else if (stringStart == stringStop){
  stringStart = stringStop = 0;
  scrollCursor = screenWidth;
 } else if (stringStop == line2.length() && scrollCursor == 0) {
  stringStart++;
 }
  else if (btnLEFT){  Â
    lcd.print(line2.substring(stringStop));
 }
 else {
  stringStart++;
  stringStop++;
 }
}
}
I understand my mistake, because I have declarated stringStop = 0
else if (btnLEFT){Â Â Â
    lcd.print(line2.substring(stringStop));
but I don't have any other idea how can I stop this.