Daylight Simulator

My Arduino Daylight Simulator is a personal project I did where I have an Arduino board control 30ft of LEDs. The purpose of this project was to simulate light in our basement where there are no windows. To do this project I got an Arduino Uno and a Real Time Clock(RTC) module, I set the time on the RTC and I have the Arduino read the time. In the morning the LEDs slowly ramp up to full brightness over a 30min time frame, and at night it slowly dims over a 30min time frame. To control the 12v LEDs with a 9v Arduino, I used a Mosfet.

Roll-a-Ball in Unity

Arduino Code

				    
                #include "DS3231.h"

                byte Year = 2020;
                byte Month = 8;
                byte Date = 14;
                byte DoW = 5;
                byte Hour = 23;
                byte Minute = 38;
                byte Second = 0;
                byte hourTest;
                byte sec;
                bool h12;
                bool PM;
                const int ledPin = 9;
                int var = 255;

                DS3231 Clock;

                void setup() {
                // Start the serial port
                Serial.begin(9600);

                // Start the I2C interface
                Wire.begin();

                //Sets clock to 24 hour
                /*
                Clock.setClockMode(false);

                Clock.setYear(Year);
                Clock.setMonth(Month);
                Clock.setDate(Date);
                Clock.setDoW(DoW);
                Clock.setHour(Hour);
                Clock.setMinute(Minute);
                Clock.setSecond(Second);
                */

                // initialize the ledPin as an output:
                pinMode(ledPin, OUTPUT);

                //Turn LED to full brightness
                analogWrite(ledPin, var);
                }

                void loop() {
                hourTest = Clock.getHour(h12, PM);
                if(hourTest == 7){
                while(var < 255){
                // set the brightness of the LED:
                analogWrite(ledPin, var);
                var++;
                delay(14000);
                }
                }

                if(hourTest == 21){
                while(var > 0){
                // set the brightness of the LED:
                analogWrite(ledPin, var);
                var--;
                delay(14000);
                }
                }

                /*
                sec = Clock.getSecond();

                if(sec == 1){
                while(var < 254){
                // set the brightness of the LED:
                analogWrite(ledPin, var);
                var++;
                delay(100);
                }
                }

                if(sec == 30){
                while(var > 1){
                // set the brightness of the LED:
                analogWrite(ledPin, var);
                var--;
                delay(100);
                }
                }


                hourTest = Clock.getHour(h12, PM);
                byte minuteTest = Clock.getMinute();
                byte secTest = Clock.getSecond();

                Serial.print(hourTest);
                Serial.print(minuteTest);
                Serial.print(secTest);
                Serial.println();
                */
                }