Want to use Arduino Time library and occasionally sync it with an external RTC (Maxim DS3231 chip). I am turning LEDs on and off based on time and using a shift register (Nexperia 74HC154PW) and encoder (ST Micro STP16CPS05TTR).
It has all been working fine, until I decided to use libraries as shown in:
https://github.com/PaulStoffregen/DS1307RTC/commit/160fa0dbca29f6fb3c1465954f89ad7f1f0fbf67
//using libraries shown in examples/SetTime
What I cannot figure out is why using #include <DS1307RTC.h> prevents the LEDs from lighting.
I have only included code below that lights the LED via a shift register to demonstrate that it runs without an error, but (have to take my word) does not light the LEDs.
If I comment out #include <DS1307RTC.h> the LEDs light.
Note that in the code below time is not used for anything.
What is including <DS1307RTC.h> doing to break it?
Puzzled.
#include <Wire.h>
#include <Time.h>
#include <TimeLib.h>
#include <DS1307RTC.h> //the problem: Will not light LEDs if this is used
//RTC used is Maxim DS323`chip
//RTC connected to ATMEGA328 pin 27 PC4(ADC4/SDA) and pin 28 (PC5 (ADC5/SCL)
//RTC works great.
//Ouputs from Atemga and Inputs into 74HC154 pins
const int A0_Pin = 4; // Atmega328 pin 2 = Arduino pin 4
const int A1_Pin = 5; // Atmega328 pin 9 = Arduino pin 5
const int A2_Pin = 2; // Atmega328 pin 32 = Arduino pin 2
const int A3_Pin = 3; // Atmega328 pin 1 = Arduino pin 3
// Shift Register STP16CPS05 has 16 outputs. Send two sets of 8 bits to turn on columns. 1 = on.
const int latchPin = 9; // Aruino Pin 9 = ATMEGA328 DIP Pin15 = TQFP Pin 13. Connected to LE-DM1 of STP16CPS05 pin 4 Latch Pin
const int clockPin = 13; // Arduino Pin 13 = ATMEGA328 DIP Pin19 = TQFP 17. Connected to CLK of STP16CPS05 pin 3 Clock Pin
const int dataPin = 17; // Arduino Pin17 = ATMEGA328 DIP Pin 26 = TQFD 26. Connected to SDI of STP16CPS05 pin 2 Data Pin (SDI)
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(A0_Pin, OUTPUT);
pinMode(A1_Pin, OUTPUT);
pinMode(A2_Pin, OUTPUT);
pinMode(A3_Pin, OUTPUT);
}
void loop() {
digitalWrite(latchPin, LOW); //LOW through inverter = HIGH = OEDisabled for both Decoder and Shift Reg
//LOW Shift Reg New Data to Buffer
digitalWrite(A0_Pin, 0);
digitalWrite(A1_Pin, 1);
digitalWrite(A2_Pin, 1);
digitalWrite(A3_Pin, 0);
shiftOut(dataPin, clockPin, LSBFIRST, B11000000);
shiftOut(dataPin, clockPin, LSBFIRST, B11111111);
digitalWrite(latchPin, HIGH); //HIGH through inverter = LOW = OE Enabled for both Decoder and Shift Reg
//HIGH Shift Reg Move data to Output pins
}