Control High-powered LEDs by Arduino and Real-Time Clock

Schematics and Coding

Design Concept
Design Schematics
Design Concept.
  • The wiring is rather simple. Only thing I would restate is to put the resistor to 5mm LED (220 ohm) and with wires connected to GND and EN pins on LED driver. I used 4.7k ohm for that last two.
  • Other independent libraries: RTClib.h, Adafruit_GFX.h, Adafruit_SSD1306.h, Adafruit_TSL2591.h. These libraries be can downloaded them via the Adafruit website or its Github.
Breadboard Implementation
Breadboard Implementation.

3.2 Moving on to Coding

First, here is the flowchart of the execution sequence

In a nutshell, I pulled a solar profile from the NREL website and averaged several days as one day. A light intensity represented in the code is in the percentage to the higest solar intensity. The Arduino pulls the time from RTC1307 with an interval, and compares with the array of time to get the closest i as a locator, and applies the intensity to the locator i from the second array. The intensity sent to the LED driver is a multiplication of the percentage and the resolution of analogWrite (255 with Arduino).

Code for Arduino

Here is the code. Just download .ino file, or copy-paste by your Arduino IDE

  • Two arrays: one for time, another for light intensity
  • Track the time from RTC and compare it to the time array in the code, get location i
  • Apply the intensity at i location, exit the loop, and apply the intensity by analogWrite
  • The heart of this code can be these lines:
DateTime now =;
float timechecker = (int)now.hour() + (float)now.minute();
for (int i=0; i<100; i ++){
    if ( hour24[i]-timechecker >=0){
        record = intensity[i];