In addition to the Trinket, LDR and Pot there’s a push-button and an LED. Pressing the button while LDRelay is running over-rides the logic to force the client device on or off.
There is an ASCII schematic in the Pins.h file in the zipped sketch.
Holding the button while turning LDRelay on goes into configuration mode. The on/off logic is reflected in the LED state, rather than driving the relay, and the pot can be adjusted to tune the desired ambient light level. Configuration mode bypasses some filtering logic.
An important tweak to the FlipClock code is a few lines to seed the PRN at power-on, add this after the call rtc.Setup() line in FlipClock.ino
// We might be connected to LDRelay. // Seed the pseudo-randomness so the behaviour doesn't (obviously) repeat every time we're tuned on: unsigned long seed = 0; byte* pByte = &rtc.m_Hour24; for (int idx = 0; idx < 6; idx++, pByte++) // hr,min,sec,weekday,date,month,year seed = (seed << 5) | *pByte; randomSeed(seed);
Some clock faces (not Flip) use pseudo-randomness. Without this code change the sequence of pseudo-random numbers would be the same each time the clock was powered on.
OK, so LDRelay is not exactly Rocket Science. It's a quite simple project, but possibly the most useful thing I've done for a while :-)