RTC schedule display

//edit: Sorry about that, code should be good now.

My latest project is an LCD display that shows the time to next bus (countdown) based on a set schedule. Im driving a 16X2 lcd and using a d1307 rtc to establish the current time.

I had previously got this functionality but I wanted to clean up the code and use an array rather than adding conditions for every time.

I’ve added all the times in the schedule into an array as minutes since midnight, converted from the time given from the RTC.

I feel like I’m close but am really struggling to get my head around the array & for loops to get the result I want.

I have included the code I have so far. I’ve just been using this for testing to try and get a feel for how this works.

Any tips as to where I am going wrong or where I can look for examples? resources I have found so far havnt been enough to get me over the line.

  example code illustrating Time library with Real Time Clock.


#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //lcd pins

int fvArray[19] = { 420, 465, 510, 555, 600, 645, 690, 735, 825, 870,
                    945, 990, 1020, 1050, 1080, 1110, 1140, 1185, 1380}; //bus times in minutes since 00:00

void setup()  {
  lcd.begin(16, 2);
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if (timeStatus() != timeSet)
    Serial.println("Unable to sync with the RTC");
    Serial.println("RTC has set the system time");


void loop()

  time_t t = now(); // Store the current time in time variable t
  int hh = hour(t);
  int mm = minute(t);
  int ss = second(t);
  int minsNow = (hh * 60) + (mm);
  //Serial.print (mins);

  for (int i = 0; i < 19 ; i++) {
    int mins = (fvArray[i]);
    if (mins < minsNow)

      Serial.println ("yes");

    else {

      Serial.println (i);



void serialClockDisplay() {
  // digital clock display of the time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");


void printDigits(int digits) {
  // utility function for digital clock display: prints preceding colon and leading 0
  if (digits < 10)

Can you:

(a) get the sketch into a state where it at least compiles. With this, it won't:

int minsNow = (hh60)+(mm);

since you have either forgotten an operator or a definition.

(b) format the code using tools -> Auto format in the IDE so there is one statement per line.