I am trying to make a clock, seems easy enough. Everything works by itself, alone. But the code seems to hang when I introduce the RTC (DS1307) library AND the tm1637 library. When running the two things together the code just hangs. so into troubleshooting
Trying to get something to work I realized that the RTC would work and send 22 as an hour (at 10pm) but once I hooked one of the wires (clock OR data) the RTC would go to 165 only and every time.
is something not i2c? I am confused on why it changes, when the device addresses are not the same.
I am using adafruit RTClib and TM1637 library from Avishay
The device is a simple i2c connection with 3.3k resistor and a 100nf cap between vcc and ground.
please help! Ill buy a new module if I need to
#include <Wire.h>
#include <TM1637Display.h>
#include "RTClib.h"
RTC_DS1307 RTC;
TM1637Display display(SCL, SDA);
int hr1, hr2, min1, min2;
void setup()
{
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop()
{
DateTime now = RTC.now();
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
display.setBrightness(0x0f);
// All segments on
display.setSegments(data);
delay(5000);
hr1 = (now.hour() / 10);
hr2 = (now.hour() % 10);
min1 = (now.minute() / 10);
min2 = (now.minute() % 10);
display.setBrightness(0x0f);
display.clear();
data[0] = display.encodeDigit(hr1);
data[1] = display.encodeDigit(hr2);
data[2] = display.encodeDigit(min1);
data[3] = display.encodeDigit(min2);
display.setSegments(data);
delay(5000);
}