Countdown timer on LCD to control servo

hey guys, i’m currently programming an auto feeder that will feed twice a day (interval of 6 hours)
the LCD is suppose to display the countdown to 2nd feeding time, but when i try to compile it a few error has occur. i’m a beginner so please help :’(
here’s my code

#include <Servo.h> // servo library
#include <LiquidCrystal.h> // LCD library
#define irLEDpin 8
#define irSensorPin 7
#define GO 1 //switch to trigger servo motor

LiquidCrystal lcd(12,11,5,4,3,2);
Servo servoFood;
Servo servoBait;

int LDRPin = 0;
int LDRvalue = 0;
int light_sensitivity = 500;
int ledPin = 7;
const int switchPin = 4;
int switchPinState = 0; 
const int feedfreqperday = 2; //the fish eats twice a day
const int numberofdays = 5; //for 5 days
const int firstfeedhour = 1;
int currenthour = 0; 
int firstminutevalue = 0;
int servoposition = 0;
int feeddone = 0;
int runninghour = 0;




void setup ()
{
  pinMode(ledPin, OUTPUT);
  pinMode(switchPin, INPUT);
  servoFood.attach(9);
  servoBait.attach(10);
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Freq:2 Days:5"); // Print the stated 
  lcd.setCursor(0,1); 
lcd.print("1st feed hour:"); // Print the stated 
lcd.setCursor (0, 2); // Choose column 0, row 2 
}
void loop ()
{
int x=analogRead(A0);

if(x<500)
{
digitalWrite(7,HIGH);
}else
{
digitalWrite(7,LOW);
}
{
 servoFood.writeMicroseconds(1300); //servo rotates clockwise to dispense food
  delay(3000); //delay for 3sec
  servoBait.writeMicroseconds(1300); // survo turns to let bait go into water
  delay(120000);
  servoFood.writeMicroseconds(1700); 
  servoBait.writeMicroseconds(1700);
}
{
for (feedfreqperday == 2); // freq input is 2
{
lcd.setCursor(9,2);
lcd.print(feedfreqperday); // total number of feed
}
}
for (runninghour = currenthour; runninghour <= 24; runninghour++) // runninghour acts as hour clock value
{
if (feeddone == feedfreqperday) // total number of feeds completed
{
setCounter = 0; // stop running the program
}
else if (feeddone < feedfreqperday) // feeds not completed
{
if (runninghour == 24) //if runninghour = 24, reset to 0 (just like hour clock)
{
lcd.setCursor(13,2);
lcd.print(" ");
runninghour = 0;
}
lcd.setCursor(13,2);
lcd.print(runninghour);
if (runninghour == firstfeedhour) // when runninghour value reaches the firstfeedhour
{
feeddone++; // feeddone will increase by 1 whenever servo rotates
lcd.setCursor(17,2);
lcd.print(feeddone);
}
secondfeedhour = firstfeedhour + 6; // 2nd feed hour calculated
if (secondfeedhour < 24)
{
newsecondfeedhour = secondfeedhour;
}
else if (secondfeedhour >= 24)
{
newsecondfeedhour = secondfeedhour - 24;
}
if (runninghour == newsecondfeedhour) // when runninghour reaches 2nd feed hour, servo rotates
{

feeddone++; // feeddone value increases
lcd.setCursor (17,2);
lcd.print(feeddone);
}
delay (21600000); // delay
}
} 
}

thanks in advance!

Hello,

Indent your code,

Then, line 62 you have

for (feedfreqperday == 2);

I suppose it should be

if (feedfreqperday == 2)

The rest is errors about undefined variables.

    #include <Servo.h> // servo library
    #include <LiquidCrystal.h> // LCD library
    #define irLEDpin 8
    #define irSensorPin 7
    #define GO 1 //switch to trigger servo motor
    
    LiquidCrystal lcd(12,11,5,4,3,2);
    Servo servoFood;
    Servo servoBait;
    
    int LDRPin = 0;
    int LDRvalue = 0;
    int light_sensitivity = 500;
    int ledPin = 7;
    const int switchPin = 4;
    int switchPinState = 0; 
    const int feedfreqperday = 2; //the fish eats twice a day
    const int numberofdays = 5; //for 5 days
    const int firstfeedhour = 1;
    int currenthour = 0; 
    int firstminutevalue = 0;
    int servoposition = 0;
    int feeddone = 0;
    int runninghour = 0;
    int setCounter = 0;
    int secondfeedhour = 0;
    int newsecondfeedhours = 0;
    
    
    
    void setup ()
    {
      pinMode(ledPin, OUTPUT);
      pinMode(switchPin, INPUT);
      servoFood.attach(9);
      servoBait.attach(10);
      lcd.begin(16,2);
      lcd.setCursor(0,0);
      lcd.print("Freq:2 Days:5"); // Print the stated 
      lcd.setCursor(0,1); 
    lcd.print("1st feed hour:"); // Print the stated 
    lcd.setCursor (0, 2); // Choose column 0, row 2 
    }
    void loop ()
    {
    int x=analogRead(A0);
    
    if(x<500)
    {
    digitalWrite(7,HIGH);
    }else
    {
    digitalWrite(7,LOW);
    }
    {
     servoFood.writeMicroseconds(1300); //servo rotates clockwise to dispense food
      delay(3000); //delay for 3sec
      servoBait.writeMicroseconds(1300); // survo turns to let bait go into water
      delay(120000);
      servoFood.writeMicroseconds(1700); 
      servoBait.writeMicroseconds(1700);
    }
    {
    if (feedfreqperday == 2); // freq input is 2
    {
    lcd.setCursor(9,2);
    lcd.print(feedfreqperday); // total number of feed
    }
    }
    for (runninghour = currenthour; runninghour <= 24; runninghour++) // runninghour acts as hour clock value
    {
    if (feeddone == feedfreqperday) // total number of feeds completed
    {
    setCounter = 0; // stop running the program
    }
    else if (feeddone < feedfreqperday) // feeds not completed
    {
    if (runninghour == 24) //if runninghour = 24, reset to 0 (just like hour clock)
    {
    lcd.setCursor(13,2);
    lcd.print(" ");
    runninghour = 0;
    }
    lcd.setCursor(13,2);
    lcd.print(runninghour);
    if (runninghour == firstfeedhour) // when runninghour value reaches the firstfeedhour
    {
    feeddone++; // feeddone will increase by 1 whenever servo rotates
    lcd.setCursor(17,2);
    lcd.print(feeddone);
    }
    secondfeedhour = firstfeedhour + 6; // 2nd feed hour calculated
    if (secondfeedhour < 24)
    {
    newsecondfeedhour = secondfeedhour;
    }
    else if (secondfeedhour >= 24)
    {
    newsecondfeedhour = secondfeedhour - 24;
    }
    if (runninghour == newsecondfeedhour) // when runninghour reaches 2nd feed hour, servo rotates
    {
    
    feeddone++; // feeddone value increases
    lcd.setCursor (17,2);
    lcd.print(feeddone);
    }
    delay (21600000); // delay
    }
    } 
    }
[code/]

i've declared the newsecondfeedhour, but the error said it is not declared. how can i fix this? :/

No, you didn't declare it, there is a difference between newsecondfeedhour and newsecondfeedhours...

And this line is still wrong:

if (feedfreqperday == 2);

Why do you put a semicolon at the end?

ahha! my bad my bad. totally didn't realize that. thank u so much, its working fine now :D