Hello, I need help to know what the problem is with my RTC (DS1307), when I upload my code, the serial monitor always displays the same date and time, the seconds are no longer advancing. I would like to know if it is a code problem or that the RTC no longer works. With my RTC, I use a 7-segment 4-digit display (+ TM1637) and a 24 neopixel ring from adafruit.
Here is my code:
#include <TM1637Display.h>
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include "RTClib.h"
#define CLK 2
#define DIO 3
TM1637Display display = TM1637Display (CLK, DIO);
TM1637Display display_1 = TM1637Display ( 2, 3 ) ;
const uint8_t data [] = { 0xff , 0xff , 0xff , 0xff } ;
const uint8_t blank [] = { 0x00 , 0x00 , 0x00 , 0x00 } ;
Adafruit_NeoPixel pixels(24, 5, NEO_GRB + NEO_KHZ800);
RTC_DS1307 rtc;
void setup () {
while (!Serial);
pixels.begin();
pixels.show();
Serial.begin(9600);
display.clear();
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
}
}
void loop () {
display.setBrightness(6);
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
int displaytime = (now.hour() * 100) + now.minute ();
display.showNumberDecEx (displaytime, 0b11100000, true);
for(int i=0; i<now.hour(); i++){
pixels.setPixelColor(i, pixels.Color(255, 0, 0));
pixels.show();
}
if (now.hour()==0){
for(int r=0; r<24; r++){
pixels.setPixelColor(r, pixels.Color(0, 0, 0));
pixels.show();
}
}
}
Thank you in advance.