Using a random number to select a switch case to display message on the LCD

Hola People!

I'm trying to use an ultra sonic sensor to create a robot which will greet/complement the people when they come close to it. The complements will be random and will be displayed on the LCD. I'm facing trouble displaying the complements on the LCD. Please help!

#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int trigPin = 8;
const int echoPin = 7;
int LEDpin = 6;
// defines variables
long duration;
int distance;
int randNumber;

void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(LEDpin, OUTPUT);
Serial.begin(9600); // Starts the serial communication
lcd.begin(16, 2);    
lcd.print("Hola!");
randomSeed(analogRead(0));
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
 distance = (duration/2) / 29.1;
Serial.print("Distance: ");
Serial.println(distance);
delay(500);
  if (distance < 20) {
    digitalWrite(LEDpin, HIGH);
     lcd.setCursor(0,1);
     randNumber = random(1,2);
     delay(500);
//Serial.println(randNumber);
switch (randNumber) {
  case 1:
   // digitalWrite(LEDpin, HIGH);
     // lcd.setCursor(0,1);
      Serial.print("1");
      lcd.print("1");
    break;
  case 2:
   //digitalWrite(LEDpin, HIGH);
     // lcd.setCursor(0,1);
      Serial.print("2");
      lcd.print("2");
      break;
   
}
      
//      lcd.print("Hi!You have the best smile");
  //    lcd.scrollDisplayLeft();
    //  delay(500); 
      
} 
  else {
    digitalWrite(LEDpin, LOW);
    lcd.setCursor(0,1);
    lcd.print("Looking for Sentient Being..");
    
    lcd.scrollDisplayLeft();
    delay(500);
    
  }

}
[code]

ultasonic___lcd_interface.ino (1.77 KB)

Please describe the "trouble" you are facing.

AWOL:
Please describe the "trouble" you are facing.

I'm unable to view the complements that needs to be displayed on the LCD Screen.

What do your serial prints tell you?

Does a simple "Hello World" program display the text on the LCD ?

     randNumber = random(1,2);

You are asking the function to give you a random number between 1 and not quite 2. There are not a lot of ints in that range, so there is nothing random about the number you get.

RTFM about the random function.