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);
}
}