1

I have a device I'm working on and the only issue I'm running into is I can't manage to figure out how to get my LCD display to move around vertically with the joystick I have attached to it. I have a feeling with a tip this could be a very simple fix, but I'm just stuck. So the brief of this is that I need someone to fill in the ???'s for me provided in my example code.

//Include the LCD Library.
#include <LiquidCrystal.h>
#include <Wire.h>
//Declare the LCD object and define pins.
#include <MFRC522.h>
#include <SPI.h>

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


#define SAD 10
#define RST 5


//Ignore The below line it is for the master code
#define I2C_ADDR    0x27 // <<----- Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);


void setup() {

//Booting the LCD
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home (); // go home
  lcd.cursor();

//Starting settings
  lcd.begin(1,0);
  lcd.clear();

}

//Sometimes you have to hit reset on the device

//Joystick Defaults X=484 Y=513

void loop() {
  lcd.setCursor(0,0);
  lcd.print("Example");
  delay(100);

for (int positionCounter = 0; positionCounter = 1; positionCounter++) {
if(analogRead(1) > 584) {
  lcd.scrollDisplayLeft();
  delay(30);
  } else if(analogRead(1) < 384) {
    lcd.scrollDisplayRight();
    delay(30);
  } else if(analogRead(0) < 413) {
     lcd.???????????????????();
     delay(30);
  } else if(analogRead(0) > 613) {
     lcd.??????????????????();
     delay(30);     
    } 
  }
}
1

The LCD library provides easy functions that activate commands in the LCD itself. The LCD doesn't have functions that do what you want, so there is no simple vertical scrolling like you're suggesting.

If you need to have it, you'll need to re-write the screen with the content you want to display when the user scrolls around. I can't make any specific suggestions as I don't know the reason you need to scroll around the display this way, but one comprehensive method would be to create a buffer of data the LCD should be displaying, then scroll it using software (move the bytes around the way you want) and then send that buffer to the LCD when it changes.

There may be other more applicable or easier tricks, but that would largely depend on your specific use case and user interface design.

1
  • Thanks a bunch, I'm pretty new to ardiuno, but I guess that makes sense I'll definetly keep it in mind, My LCD was dumping a large amount of data to the screen and it was dumping it line after line so I just wanted to be able to scroll through all the data.. I'm good for now tho I put a "band-aid" on the problem – malcolm hartley May 15 '15 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.