Problem with RTC module program

Hello, I am having trouble with a project where I need to use an RTC module and serial monitor, every time I take out the code that uses the RTC the serial monitor works, but when I add the RTC code, the Serial monitor stops working.
BTW I am using ds1307
I have tried:
-Checking my wiring dozens of time
-re arranging the RTC.begin(); Wire.begin(); and Serial.begin(9600);

  • changing object names
    Does anyone know what's going on? I've used this module before and I used my old code, but that doesn't work anymore for some reason.
    Here's my code.
#include <Servo.h>
#include <Wire.h>
#include <RTClib.h>
int sp = 14;
int lp = A5;
boolean button_status;
int button_pin = 2;
int lv;
RTC_DS1307 RTC; 
int tmins = 0;
int thours = 0;
Servo servo;
void setup() {
    servo.attach(sp);
    Wire.begin();
    RTC.begin();
    Serial.begin(9600);
}

void loop() {
      DateTime now = RTC.now();
     thours = now.hour();
     tmins = now.minute();
delay(500);
  lv = analogRead(lp);
  delay(500);
  button_status = digitalRead(button_pin);
if(thours > 17 && lv < 600){
  if(button_status == false){
  servo.write(90);
  delay(500);
  servo.write(0);
  }
}
if(lv > 0){
  servo.write(20);
  delay(500);
  servo.write(70);
  delay(500);
}
}

You seem to be using A5 as an analog pin. Don't you need it for I2C to talk to the clock?

What does that mean? The posted program does not do anything with the serial monitor.

How Arduino I2C works.

Nice You used code tags!
If You also use the autoformat, CTRL T, in the IDE, the presentation will be really excellent, more easy to read.

1 Like

Oh whoops I posted the wrong code!

Thank you @groundFungus I got it working!