LCD quick question

Hi guys I hope this is a quick question to answer but when I first started using an arduino I tried using some of my uni's tutorials and in them using the LiquidCrystal library I was able to make the second row of the LCD scroll just using something along the lines of set.Cursor(0,xp+1); for some reason this isnt correct if someone whose used this before could help that would be great.
thank you in advance.
P

Please post your best attempt

this is all I've got really

   lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Diagnostics");
    lcd.setCursor(0,px+1);
    lcd.print("Recorded RPM: ");
    lcd.print(lastRPM);
    lcd.setCursor(0,px+1);

The parameters to the function are column and row in that order. How many rows are there in your display. Where does the value of px come from and what is its value ?

We need to see your code in context and not just a snippet of it

#include <dht.h>
#include <LiquidCrystal.h>
#include <Arduino.h>
#include <stdio.h>
 
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

dht DHT;


int ledPin = 13;
#define VibSensor  A5

unsigned long prevMillis = 0;
unsigned long interval = 10;
unsigned long currentMillis = millis();

//-----THERMISTER SET UP-----//

int ThermistorPin = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

//-------DHT11 SENSOR SET UP-------//

#define DHT11_PIN 2
#define ON 1
#define OFF 0


//-------LCD BUTTON SET UP-------//

#define Button 5
int lastState = LOW;  // the previous state from the input pin
int currentState; 

int LCDmode = 0;
int oldLCDmode = 0;

//-------IR SENSOR SET UP-------//

const int IRSensor = 4; //IR sensor INPUT

unsigned long prevmillis; // To store time
unsigned long duration; // To store time difference
unsigned long lcdrefresh; // To store time for lcd to refresh

int rpm; // RPM value

boolean currentstate; // Current state of IR input scan
boolean prevstate; // State of IR sensor in previous scan

//-------WARNINGS SET UP-------//

#define GLED 13
#define buzzer 3
#define RLED 6
int VibErrors = 0;
int oldVibErrors = 0;
int lastRPM = 0;
int oldRPM = 0;
int lastT;

unsigned long time_now = 0;
void setup(){
  pinMode(ledPin, OUTPUT);
  pinMode(RLED, OUTPUT);
  pinMode(VibSensor, INPUT); 
  Serial.begin(9600); 
  lcd.begin(16,2);
  pinMode(IRSensor,INPUT);
}
void loop(){
 Vibration();
 Buttons();
 Modes();
}

 void Modes() {

  switch (LCDmode) {
    case 1:
      thermistor();
      oldLCDmode = LCDmode;
      break;
    case 2:
      middleTemp();
      oldLCDmode = LCDmode;
      break;
    case 3:
      rpm_measurement();
      oldLCDmode = LCDmode;
      break;
    case 4:
      Errors();
      oldLCDmode = LCDmode;
    default:
      temperature_sensor();
      oldLCDmode = 0;
      break;
  }
}

//VIBRATION IN FREQUENCY FUNCTIONS//


  void Vibration(){
  long measurement = TP_init();
  unsigned long currentMillis = millis();
if (currentMillis - prevMillis >= interval) {
 // Serial.print("measurment = ");
 // Serial.println(measurement);
  if (measurement > 1000){
    digitalWrite(ledPin, HIGH);
    tone(buzzer, 3000);
    VibErrors = oldVibErrors + 1;
  }
  else{
    digitalWrite(ledPin, LOW);
    noTone(buzzer); 
  }
  prevMillis = currentMillis;
}
}
long TP_init(){
  
if (currentMillis - prevMillis >= interval) {
  long measurement=pulseIn (VibSensor, HIGH);  //wait for the pin to get HIGH and returns measurement
  return measurement;
  prevMillis = currentMillis;
}
}


//TEMP FUNCTION//


void temperature_sensor(){  

  unsigned long period = 1500;
  unsigned long currentTime = millis();

  if (currentTime - time_now >= period){
    
  int chk = DHT.read11(DHT11_PIN);
  int t = DHT.temperature;;
  int h= DHT.humidity;
  lcd.clear();
  lcd.setCursor(0,0); 
  lcd.print("Inlet Temp: ");
  lcd.print(t);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");

  if (t > 25){                            // set dangerous temperature
    digitalWrite(RLED,HIGH);
    tone(buzzer, 3000);
  }else{
    digitalWrite(RLED,LOW);
    noTone(buzzer);
  }
  
  time_now = currentTime;
  }
}


//RPM FUNCTION//


void rpm_measurement(){

  // RPM Measurement
  currentstate = digitalRead(IRSensor); // Read IR sensor state
 if( prevstate != currentstate) // If there is change in input
   {
     if( currentstate == HIGH ) // If input only changes from LOW to HIGH
       {
         duration = ( micros() - prevmillis ); // Time difference between revolution in microsecond
         rpm = (60000000/duration); // rpm = (1/ time millis)*1000*1000*60;
         prevmillis = micros(); // store time for next revolution calculation
         lastRPM = rpm;
       }
   }
  prevstate = currentstate; // store this scan (prev scan) data for next scan

    
  // LCD Display
  if( ( millis()-lcdrefresh ) >= 100 )
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Speed of Motor");
      lcd.setCursor(0,1);
      lcd.print("RPM = ");
      lcd.print(rpm);   // Devided by the number of blades so that we can have an accurate reading on how many times one of those blades passes through the sensor instead of how many things pass in front of the sensor        
      lcdrefresh = millis(); 
    } 
}

 void thermistor(){

  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T = T - 273.15;
  T = T - 56; // calibration of temperature

unsigned long period = 1000;
unsigned long currentTime = millis();

  if (currentTime - time_now >= period){
  lcd.clear();
  lcd.setCursor(0,0); 
  lcd.print("Outlet Temp: ");
  lcd.setCursor(0,1);
  lcd.print(T);
  lcd.print((char)223);   
  lcd.print("C");

  time_now = currentTime;
}
}

void middleTemp(){
  int chk = DHT.read11(DHT11_PIN);
  int t = DHT.temperature;
  
  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T = T - 273.15;
  T = T - 56;
  T = T - t;
  lastT = T;
unsigned long period = 1000;
unsigned long currentTime = millis();

  if (currentTime - time_now >= period){
  lcd.clear();
  lcd.setCursor(0,0); 
  lcd.print("Internal Temp: ");
  lcd.setCursor(0,1);
  lcd.print(T);
  lcd.print((char)223);   
  lcd.print("C");

  time_now = currentTime;
}
} 
  

//BUTTON FUNCTION//


void Buttons(){
currentState = digitalRead(Button);

  if(lastState == LOW && currentState == HIGH){
    Serial.println("The button is pressed");
    LCDmode = oldLCDmode + 1;
  }
  else if(lastState == HIGH && currentState == LOW){
    Serial.println("The button is released");
  // save the the last state
  }
  lastState = currentState;

}
void Errors(){
  
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Diagnostics");
    lcd.setCursor(0,xp+1);
    lcd.print("Recorded RPM: ");
    lcd.print(lastRPM);
  Serial.println("Errors");
  Serial.println("Recorded RPM: ");
  Serial.println(lastRPM);
  Serial.println("Excess Vibrations: ");
  Serial.println(VibErrors);
  Serial.println("Interior Temperature: ");
  Serial.println(lastT);
}

I didn’t want to put all of my code because it could be too much, also the px came from me trying xp first and i thought it couldve been px but it isnt unfortunately i cant remember what it was

Still no sign of where px (or is it xp ?) comes from or its value but it it ever exceeds 1 then the cursor will be off the screen. Remember, column then row when positioning the cursor position

so do I just need to make it an int and it should work?

Think about it

lcd.clear();  //clear the LCD - it also postions the cursor at column 0, row 0
lcd.setCursor(0, 0);  //so this is not strictly necessary
lcd.print("Diagnostics"); //print 11 characters - cursor now at 11
lcd.setCursor(0, xp + 1); //move the cursor to column 0 row (xp + 1)
lcd.print("Recorded RPM: ");  //print 14 characters - where will they print ?

Suppose xp is 0 - where will "Recorded RPM: " be printed ?
Suppose xp is 1 - where will "Recorded RPM: " be printed then ?

You have not shown where the value of xp comes from or what it might be