Converting number to a string for the LCD display goes ape

So what I'm trying to do is to make an alarm clock.

int time_h = 18;
int time_m = 29;
int alarm_h = 18;
int alarm_m = 30;
int alarmState = 0;

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  lcd.print("Time:  ");
  lcd.setCursor(0,1);
  lcd.print("Alarm: ");
}

void loop()
{
  int x;
  
  x = analogRead (0);
  lcd.setCursor(7,0);
  lcd.print((char)time_h + ":" + (char)time_m);
  lcd.setCursor(7,1);
  lcd.print((char)alarm_h + ":" + (char)alarm_m);
  
  if (x < 60) {
    time_m = time_m+60;
    delay(250);
  }
  else if (x < 200) {
    time_h = time_h+1;
    delay(250);
  }
  else if (x < 400){
    alarm_m = alarm_m+1;
    delay(250);
  }
  else if (x < 600){
    alarm_h = alarm_h+1;
    delay(250);
  }
  else if (x < 800){
    alarmState = 0;
  }
  
  if(alarm_m == time_m & alarm_h == time_h){
    alarmState = 1;
  }

  if(alarmState==1){
     //make the alarm go off
  }
}

Leaves me with this:

So what I'm asking is how do I successfully convert a number into a string? Found the casting method by doing (type)variable, but it doesn't seem to work

  lcd.print(time_h);
  lcd.print (":");
  lcd.print (time_m);

etc.

When you've fixed that, you may want to add some leading zeroes.

lcd.print((char)time_h + ":" + (char)time_m);That is not how you concatenate chars, not that you need to in order to print them.

int time_h = 18;
int time_m = 29;
int alarm_h = 18;
int alarm_m = 30;
int alarmState = 0;

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  lcd.print("Time:  ");
  lcd.setCursor(0,1);
  lcd.print("Alarm: ");
}

void loop()
{
  int x;
  x = analogRead (0);
  
  //TIME
  if(time_h < 10)
  {
    lcd.setCursor(7,0);
    lcd.print("0");
    lcd.print(time_h);
  }
  else
  {
    lcd.setCursor(7,0);
    lcd.print(time_h);
  }
  lcd.setCursor(9,0);
  lcd.print(":");
  lcd.print(time_m);

  //ALARM
  if(alarm_h < 10)
  {
    lcd.setCursor(7,0);
    lcd.print("0");
    lcd.print(alarm_h);
  }
  else
  {
    lcd.setCursor(7,0);
    lcd.print(alarm_h);
  }
  lcd.setCursor(9,0);
  lcd.print(":");
  lcd.print(alarm_m);
  
  if (x < 60) {
    time_m = time_m+60;
    delay(250);
  }
  else if (x < 200) {
    time_h = time_h+1;
    delay(250);
  }
  else if (x < 400){
    alarm_m = alarm_m+1;
    delay(250);
  }
  else if (x < 600){
    alarm_h = alarm_h+1;
    delay(250);
  }
  else if (x < 800){
    alarmState = 0;
  }
  
  if(alarm_m == time_m & alarm_h == time_h){
    alarmState = 1;
  }

  if(alarmState==1){
     //make the alarm go off
  }
}

Didn't quiiiiite advance positively

Try:

char buff[16];
sprintf(buff, "Time: %02d:%02d", time_h, time_m);
lcd.print(buff);

Start debugging.

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  lcd.begin(16, 2);

  lcd.setCursor(0,0);
  lcd.print("Time:  ");
  lcd.setCursor(0,1);
  lcd.print("Alarm: ");
}

void loop()
{}

(uncompiled, untested)

#include <LiquidCrystal.h>

int time_h;
int time_m;
const int ONE_SECOND = 1000;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  lcd.begin(16, 2);

  lcd.setCursor(0,0);
  lcd.print("Time:  ");
  lcd.setCursor(0,1);
  lcd.print("Alarm: ");
}

void loop()
{
  static unsigned long previousUpdateTime;
  unsigned long timeNow = millis ();
  
  if (timeNow - previousUpdateTime >= ONE_SECOND)
  {
    previousUpdateTime += ONE_SECOND;
    lcd.setCursor(7,0);
    leadZeroes (time_h);
    lcd.print (":");
    leadZeroes (time_m++);

    if (time_m == 60)
    {
      time_m = 0;
      time_h++;
      if (time_h == 24)
      {
        time_h = 0;
      }
    }
  }
}

void leadZeroes (int x)
{
  if (x < 10)
  {
    lcd.print ("0");
  }
  lcd.print (x);
}

IT'S ALIVE!!!

int time_h;
int time_m;
int alarm_h;
int alarm_m;
int alarmState = 0;

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
}

void loop()
{
  int x;
  time_m = millis()/60000;
  time_h = time_m/60;
  x = analogRead (0);
  
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  char t[16];
  sprintf(t, "Time:  %02d:%02d", time_h, time_m);
  lcd.print(t);
  
  lcd.setCursor(0,1);
  char a[16];
  sprintf(a, "Alarm: %02d:%02d", alarm_h, alarm_m);
  lcd.print(a);
  
  if (time_m == 60)
  {
    time_m = 0;
    time_h++;
    if (time_h == 24)
    {
      time_h = 0;
    }
  }
    
  if (x < 60) {
    if(time_m >= 59)
    {
      time_m = 0;
    }
    else
    {
      time_m++;
    }
    delay(250);
  }
  else if (x < 200) {
    if(time_h >= 23)
    {
      time_h = 0;
    }
    else
    {
      time_h++;
    }
    delay(250);
  }
  else if (x < 400){
    if(alarm_m >= 59)
    {
      alarm_m = 0;
    }
    else
    {
      alarm_m++;
    }
    delay(250);
  }
  else if (x < 600){
    if(alarm_h >= 23)
    {
      alarm_h = 0;
    }
    else
    {
      alarm_h++;
    }
    delay(250);
  }
  else if (x < 800){
    alarmState = 0;
  }
  
  if(alarm_m == time_m & alarm_h == time_h){
    alarmState = 1;
  }

  if(alarmState==1){
     //make the alarm go off
  }
}

Thanks guys for the help!