Turn servo when given time and rtc matches


This was the output for the complete strings. I showed both versions, substring and complete string. As you mention if even substrings do not match, there's no difference. The latest code is below. I have only removed the substring that's all. 22:15:20 for RTC and 22:15:20 for input from keypad. The 0 is the result for comparison.

#include <Keypad.h>
#include <DS1302.h>
#include <Servo.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
 
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'A','3','2','1'},
  {'B','6','5','4'},
  {'C','9','8','7'},
  {'D','#','0',':'}
};
 
byte rowPins[ROWS] = {10, 11, 12, 13}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad
char key;
String feedTime;
boolean feed = true; // condition for alarm
char t1, t2, t3, t4, t5, t6;


//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
// Init the DS1302
DS1302 rtc(4, 3, 5);
Servo servo_test;      //initialize a servo object for the connected servo  
int c = 0;
void setup(){

  
  servo_test.attach(2);   // attach the signal pin of servo to pin9 of arduino
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  servo_test.write(55); 
  rtc.writeProtect(false);
  Serial.begin(9600);
  feedTime = "";
  // The following lines can be commented out to use the values already stored in the DS1302
  rtc.setDOW(FRIDAY);        // Set Day-of-Week to FRIDAY
  rtc.setTime(22, 15, 00);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(11, 9, 2021);   // Set the date to August 6th, 2010
}
 
void loop(){

  // Send Day-of-Week
  //Serial.print(rtc.getDOWStr());
  //Serial.print(" ");
  
  // Send date
  //Serial.print(rtc.getTimeStr());
  //Serial.print(" -- ");

  // Send time
  
  
  // Wait one second before repeating :)
  char customKey = customKeypad.getKey();
  if (customKey == '#'){
        setFeedingTime();
                   
  }
  String t = "";
  t = rtc.getTimeStr();
 
   
  
      
  
   if ( t.equals(feedTime)&& feed==true)
 { 
   servo_test.write(100);                   //command to rotate the servo to the specified angle 
   delay(400);   
   servo_test.write(55); 
   Serial.println("IT WORKS!!!!");
   feed = false;
  } 
  Serial.print(t);
  Serial.print("-");
  Serial.print(feedTime);
  Serial.print("-");
  delay(50);
  Serial.print(t.equals(feedTime)); 
  Serial.println();
  delay(1000);
}


void setFeedingTime()
{
  
  feedTime = "";
  Serial.println("\nPlease enter feeding time: ");
  while(1){
    key = customKeypad.getKey();


  if (key == '#')
 {
  key=0;
  Serial.println("\nFeeding time set to: ");
  Serial.print(feedTime);
  feed = true;
 
  break; }
  
  else{
    Serial.print(key);
    delay(50);
    feedTime.concat(key);
   
    
  }
  }
}