Project showcase
Automated Night Light

Automated Night Light © GPL3+

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

  • 3,137 views
  • 0 comments
  • 13 respects

Components and supplies

About this project

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 Team RobotGeek Projects Team

  • 2,220 views
  • 1 comment
  • 6 respects

Night Light Assistant

Project showcase by Gabriele Fugazzi

  • 5,266 views
  • 9 comments
  • 23 respects

Motion Activated Night Light

Project tutorial by Haziq Afandi

  • 5,563 views
  • 0 comments
  • 6 respects

Neopixel Motion Activated Night Light

Project tutorial by Becky Ellis

  • 4,265 views
  • 4 comments
  • 10 respects

LEGO-Compatible Night Light

Project tutorial by Lunchbox Electronics

  • 2,841 views
  • 3 comments
  • 19 respects

Controlling LED light intensity using smartphone light senso

Project tutorial by Nikola Travis

  • 2,815 views
  • 0 comments
  • 1 respect
Add projectSign up / Login