Okay, Ive been playing with the Evil Genius binary clock and I added a RTC to keep the time accurate.
Final problem is that the LED on lilypad pin 1 remains high. It does appear to flash off with the updateDisplay routine, but essentially it is on all the time.
I can see the time on the serial monitor and also advance the time, but it always remain on with some brief flashes off during uploading or as listed above.
Des anyone see something causing this?
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
int switchPin = 11;
int hourLEDs[] = {4, 3, 2, 1}; // least significant bit first
int secondLEDs[] = {10, 9, 8, 7, 6, 5};
int minuteLEDs[] = {17, 16, 15, 14, 13, 12};
int loopLEDs[] = {4, 3, 2, 1, 17, 16, 15, 14, 13, 12, 10, 9, 8, 7, 6, 5};
void setup()
{
for (int i = 0; i < 4; i++)
{
pinMode(hourLEDs*, OUTPUT);*
- }*
- for (int i = 0; i < 6; i++)*
- {*
_ pinMode(minuteLEDs*, OUTPUT);_
_ }_
_ for (int i = 0; i < 6; i++)_
_ {_
_ pinMode(secondLEDs, OUTPUT);
}*_
* Serial.begin(9600);*
* setSyncProvider(RTC.get); // the function to get the time from the RTC*
}
*void loop() *
{
* if (digitalRead(switchPin))*
* {*
* adjustTime(60-second()); // Move the clock forward to the next minute *
* RTC.set(now()); // Set the RTC to the new time*
* delay(100);*
* }*
* else if (minute() == 0 && second() == 0)*
* {*
* spin(hour());*
* }*
* updateDisplay();*
* delay(100);*
}
void updateDisplay()
{
* //setSyncProvider(RTC.get);*
* //time_t t = now();
_ setOutput(hourLEDs, 4, hourFormat12());
setOutput(minuteLEDs, 6, minute());
setOutput(secondLEDs, 6, second());*_
* Serial.print(hourFormat12());*
* printDigits(minute());*
* printDigits(second());*
* Serial.println();*
}
void printDigits(int digits){
* // utility function for digital clock display: prints preceding colon and leading 0*
* Serial.print(":");*
* if(digits < 10)*
* Serial.print('0');*
* Serial.print(digits);*
}
void setOutput(int *ledArray, int numLEDs, int value)
{
* for (int i = 0; i < numLEDs; i++)*
* {*
_ digitalWrite(ledArray*, bitRead(value, i));
}
}
void spin(int count)
{
for (int i = 0; i < count; i++)
{
for (int j = 0; j < 16; j++)
{
digitalWrite(loopLEDs[j], HIGH);
delay(25);
digitalWrite(loopLEDs[j], LOW);
}
}*_
* setSyncProvider(RTC.get);*
}