Project showcase
Automated Night Light

Automated Night Light © GPL3+

It is an automated night lamp based with a real time clock.

  • 6,247 views
  • 3 comments
  • 19 respects

Components and supplies

About this project

Buy electronic components with free shipping on utsource.net

Step 1: Connect the Circuit as shown in the figure

Step 2: Upload the Code

Link to .ino (Arduino software File):  

// Date and time functions using RX8025 RTC connected via I2C and Wire lib 
#include <Wire.h>
#include "Sodaq_DS3231.h"
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
const int ledPin = 13;
void setup ()
{
Serial.begin(57600);
Wire.begin();
rtc.begin();
}
uint32_t old_ts;
void loop ()
{
DateTime now = rtc.now(); //get the current date-time
uint32_t ts = now.getEpoch();
if (old_ts == 0 || old_ts != ts) {
old_ts = ts;
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.date(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.print(weekDay[now.dayOfWeek()]);
Serial.println();
Serial.print("Seconds since Unix Epoch: ");
Serial.print(ts, DEC);
Serial.println();
}
delay(1000);
if (now.hour() > 17 || now.hour() < 7)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}

Code

Comments

Similar projects you might like

RobotGeek PIR Motion Sensor Night Light

Project tutorial by RobotGeek Projects Team

  • 4,524 views
  • 2 comments
  • 8 respects

Motion Activated Night Light

Project tutorial by Haziq Afandi

  • 12,336 views
  • 4 comments
  • 11 respects

Arduino Automated Parking Garage

Project tutorial by ashraf_minhaj

  • 17,666 views
  • 11 comments
  • 35 respects

Night Light Assistant

Project showcase by Gabriele Fugazzi

  • 8,545 views
  • 10 comments
  • 26 respects

RGB LED Avatar Aang Night Light

Project showcase by gurpr337

  • 962 views
  • 1 comment
  • 1 respect

Automated Light Switch

Project tutorial by Hung-Che

  • 8,516 views
  • 3 comments
  • 18 respects
Add projectSign up / Login